net: add ETH_P_FCOE for Fibre Channel over Ethernet (FCoE)
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/7 net: add ETH_P_FCOE for Fibre Channel over Ethernet (FCoE)
This adds eth type ETH_P_FCOE for Fibre Channel over Ethernet (FCoE)
---
include/linux/if_ether.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/if_ether.h +1 -0
@@ -78,6 +78,7 @@#define ETH_P_PAE 0x888E/* Port Access Entity (IEEE 802.1X) */ #define ETH_P_AOE 0x88A2/* ATA over Ethernet */ #define ETH_P_TIPC 0x88CA/* TIPC */ +#define ETH_P_FCOE 0x8906/* Fibre Channel over Ethernet */ #define ETH_P_EDSA 0xDADA/* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ /*
PATCH 2/7 net: add FCoE offload support through net_device
In reply to a message not in the archiveThis adds a "struct net_fcoe_ops *fcoe_ops" to net_device struct so any network adapter driver can provide Fiber Channle over Ethernet (FCoE) offload support through net_device. The fcoe_ops is only available when FCoE is enabled in kernel as built-in or module driver.
---
include/linux/netdevice.h | 8 ++++++++ include/linux/netfcoe.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 0 deletions(-) create mode 100644 include/linux/netfcoe.h
include/linux/netdevice.h +8 -0
@@ -47,6 +47,10 @@#include <net/dcbnl.h> #endif +#if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE ) +#include <linux/netfcoe.h> +#endif +struct vlan_group ;struct ethtool_ops ;struct netpoll_info ;
@@ -840,6 +844,10 @@ struct net_devicestruct dcbnl_rtnl_ops *dcbnl_ops;#endif +#if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE ) +struct net_fcoe_ops *fcoe_ops; +#endif + #ifdef CONFIG_COMPAT_NET_DEV_OPS struct { int (*init)(struct net_device *dev);
include/linux/netfcoe.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright(c) 2007 - 2009 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +* +* Maintained at www.Open-FCoE.org +*/ +#ifndef __NET_FCOE_H__ +#define __NET_FCOE_H__ + +#define NET_FCOE_CRC (1 << 0)/* FC CRC32 offload */ +#define NET_FCOE_LSO (1 << 1)/* Large send offload */ +#define NET_FCOE_LRO (1 << 2)/* Large receive offload */ +/* +* Ops struct for FCoE enabled drivers to callback through the netdevice struct +*/ +struct net_fcoe_ops { +u16 lro_xid; +u32 features; +int (*ddp_setup)(struct net_device *netdev,u16 xid, +struct scatterlist *sgl,unsigned int nents); +int (*ddp_done)(struct net_device *netdev,u16 xid); +}; + +#endif /* __NET_FCOE_H__ */
Re: [PATCH 2/7] net: add FCoE offload support through net_device
Quoted 6 lines · On Thu, 19 Feb 2009 12:49:49 -0700 Yi Zou <[email protected]> wrote:
This adds a "struct
net_fcoe_ops*fcoe_ops" tonet_devicestruct so any network adapter driver can provide Fiber Channle over Ethernet (FCoE) offload support throughnet_device. Thefcoe_opsis only available when FCoE is enabled in kernel as built-in or module driver.Signed-off-by Yi Zou <[email protected]>
Rather than adding another _ops structure please add to existing netdevice_ops. You don't need the flags that way. If netdevice_ops has fcoe_setup, then device can do it...
RE: [PATCH 2/7] net: add FCoE offload support through net_device
Quoted 8 lines
Quoted 1 line · On Thu, 19 Feb 2009 12:49:49 -0700 Yi Zou <[email protected]> wrote:
This adds a "struct
net_fcoe_ops*fcoe_ops" tonet_devicestruct soany
Quoted 1 line
network adapter driver can provide Fiber Channle over Ethernet (FCoE)
offload
Quoted 1 line
support through
net_device. Thefcoe_opsis only available when FCoE
Quoted 8 lines
is
Quoted 3 lines
enabled in kernel as built-in or module driver.
Signed-off-by Yi Zou <[email protected]>Rather than adding another
_opsstructure please add to existingnetdevice_ops. You don't need the flags that way. Ifnetdevice_opshasfcoe_setup, then device can do it...
The comments in struct net_device_ops says for management hooks, if that's an ok place for net_fcoe_ops, then, I am all for it.
Thanks.
yi
RE: [PATCH 2/7] net: add FCoE offload support through net_device
Quoted 16 lines
Quoted 8 lines
Quoted 1 line · On Thu, 19 Feb 2009 12:49:49 -0700 Yi Zou <[email protected]> wrote:
This adds a "struct
net_fcoe_ops*fcoe_ops" tonet_devicestruct soany
Quoted 1 line
network adapter driver can provide Fiber Channle over Ethernet (FCoE)
offload
Quoted 1 line
support through
net_device. Thefcoe_opsis only available when FCoEQuoted 8 lines
is
Quoted 3 lines
enabled in kernel as built-in or module driver.
Signed-off-by Yi Zou <[email protected]>Rather than adding another
_opsstructure please add to existingnetdevice_ops. You don't need the flags that way. Ifnetdevice_opshasfcoe_setup, then device can do it...
Quoted 6 lines
The comments in struct
net_device_opssays for management hooks, if that's an ok place fornet_fcoe_ops, then, I am all for it.Thanks.
yi
Hi, Stephen,
Regarding your comment about adding net_fcoe_ops to net_device_ops, the net_fcoe_ops contains function pointers ad well as data members, where net_device_ops seems to me is the placeholder only for function pointers. So I think it is still better to still leave
the net_fcoe_ops to net_device. Let me know what you think.
Thanks,
yi
Re: [PATCH 2/7] net: add FCoE offload support through net_device
Quoted 30 lines · Yi
Quoted 16 lines
Quoted 8 lines
Quoted 1 line · On Thu, 19 Feb 2009 12:49:49 -0700 Yi Zou <[email protected]> wrote:
This adds a "struct
net_fcoe_ops*fcoe_ops" tonet_devicestruct soany
Quoted 1 line
network adapter driver can provide Fiber Channle over Ethernet (FCoE)
offload
Quoted 1 line
support through
net_device. Thefcoe_opsis only available when FCoEQuoted 8 lines
is
Quoted 3 lines
enabled in kernel as built-in or module driver.
Signed-off-by Yi Zou <[email protected]>Rather than adding another
_opsstructure please add to existingnetdevice_ops. You don't need the flags that way. Ifnetdevice_opshasfcoe_setup, then device can do it...Quoted 6 lines
The comments in struct
net_device_opssays for management hooks, if that's an ok place fornet_fcoe_ops, then, I am all for it.Thanks.
yi
Hi, Stephen,
Regarding your comment about addingnet_fcoe_opstonet_device_ops, thenet_fcoe_opscontains function pointers ad well as data members, wherenet_device_opsseems to me is the placeholder only for function pointers. So I think it is still better to still leave
thenet_fcoe_opstonet_device. Let me know what you think.
Quoted 2 lines
Thanks,
yi
Data members go in net_device (because they are per device instance). Put fcoe stuff in net_device_ops. Ideally, it should look like TSO and GRO; with standard ethtool type config?
PATCH 3/7 fcoe: check offload features from LLD through netdev
In reply to a message not in the archiveThis checkes if net_devices supports net_fcoe_ops, if it does, then sets up the corresponding flags in the associated fc_lport.
Note that large sequence offload is already supported in the current libfc/fcoe, only thing needed is to tell the corresponding fc_lport that LLD is capabale of doing so by using fcoe_ops->features.
---
drivers/scsi/fcoe/fcoe_sw.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
drivers/scsi/fcoe/fcoe_sw.c +27 -0
@@ -188,6 +188,33 @@ static int fcoe_sw_netdev_config(struct fc_lport *lp, struct net_device *netdev)if (fc->real_dev->features &NETIF_F_SG ) lp->sg_supp =1 ; + lp->crc_offload =0 ; + lp->seq_offload =0 ; + lp->lro_enabled =0 ; +if (netdev->fcoe_ops) { +struct net_fcoe_ops *fops = netdev->fcoe_ops; + +if (fops->features &NET_FCOE_CRC ) { + lp->crc_offload =1 ; +FCOE_DBG ("%s supports FCoE FCCRC offload\n" , + netdev->name); + } + +if (fops->features &NET_FCOE_LSO ) { + lp->seq_offload =1 ; +FCOE_DBG ("%s supports FCoE large send offload\n" , + netdev->name); + } + +if ((fops->features &NET_FCOE_LRO ) && + (fops->lro_xid)) { + lp->lro_enabled =1 ; + lp->lro_xid = fops->lro_xid; +FCOE_DBG ("%s supports FCoE large receive offload " +"with max read exchange id for ddp %d\n" , + netdev->name, lp->lro_xid); + } + }skb_queue_head_init (&fc->fcoe_pending_queue);
PATCH 4/7 libfc: add support of large receive offload by ddp in fc_fcp
In reply to a message not in the archiveWhen LLD supports direct data placement (ddp) for large receive of an scsi i/o coming into fc_fcp, we call into libfc_function_template's ddp_setup() to prepare for a ddp of large receive for this read I/O. When I/O is complete, we call the corresponding ddp_done() to get the length of data ddped as well as to let LLD do clean up.
Summary of changes:
1. Added ddp_setup()/ddp_done() to libfc_function_template and they are expected to be impleted by fcoe layer
2. Added exch_send() to seperate exch_alloc() from exch_seq_send in fc_fcp_cmd_send() since that's where we call ddp_setup() and we have to have know the exchange xid.
3. Added calling lp->tt.ddp_setup() for read I/O if lro_enabled is set. When ddp_setup is successful, xfer_ddp stores the corresponding exchange xid.
4. Added calling lp->tt.ddp_done() to fc_fcp_resp() to update the xfer_len for the case of a normal complete ddp and let the LLD release ddp resource.
5. Added calling lp->tt.ddp_done() to fc_fcp_recv_data() to update the xfer_len for the case of an incomplete ddp
6. Added calling lp->tt.ddp_done() to fc_io_compl() for an ddped I/O to make sure ddp resource is released in case of abort
7. Also removed clearing of lro_enabled flag in fc_exch_mgr_alloc() since that is taken care of by fcoe_sw_netdev_config() now.
---
drivers/scsi/libfc/fc_exch.c | 46 +++++++++++++++++++++++++++--------------- drivers/scsi/libfc/fc_fcp.c | 36 +++++++++++++++++++++++++++++++-- include/scsi/libfc.h | 46 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 18 deletions(-)
drivers/scsi/libfc/fc_exch.c +30 -16
@@ -1753,9 +1753,6 @@ struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp, mp->max_read = lp->lro_xid; mp->last_read = min_xid -1 ; mp->last_xid = mp->max_read; - }else { -/* disable lro if no xid control over read */ - lp->lro_enabled =0 ; }INIT_LIST_HEAD (&mp->ex_list);
@@ -1795,24 +1792,19 @@ struct fc_exch *fc_exch_get(struct fc_lport *lp, struct fc_frame *fp) }EXPORT_SYMBOL (fc_exch_get); -struct fc_seq *fc_exch_seq_send (struct fc_lport *lp, -struct fc_frame *fp, -void (*resp)(struct fc_seq *, -struct fc_frame *fp, -void *arg), -void (*destructor)(struct fc_seq *,void *), -void *arg,u32 timer_msec) +struct fc_seq *fc_exch_send (struct fc_lport *lp, +struct fc_exch *ep, +struct fc_frame *fp, +void (*resp)(struct fc_seq *, +struct fc_frame *fp, +void *arg), +void (*destructor)(struct fc_seq *,void *), +void *arg,u32 timer_msec) { -struct fc_exch *ep;struct fc_seq *sp =NULL ;struct fc_frame_header *fh;int rc =1 ; - ep = lp->tt.exch_get (lp, fp); -if (!ep) { -fc_frame_free (fp); -return NULL ; - } ep->esb_stat |=ESB_ST_SEQ_INIT ; fh =fc_frame_header_get (fp);fc_exch_set_addr (ep,ntoh24 (fh->fh_s_id),ntoh24 (fh->fh_d_id));
@@ -1846,6 +1838,25 @@ err:fc_exch_mgr_delete_ep (ep);return NULL ; } +EXPORT_SYMBOL (fc_exch_send); + +struct fc_seq *fc_exch_seq_send (struct fc_lport *lp, +struct fc_frame *fp, +void (*resp)(struct fc_seq *, +struct fc_frame *fp, +void *arg), +void (*destructor)(struct fc_seq *,void *), +void *arg,u32 timer_msec) +{ +struct fc_exch *ep; + + ep = lp->tt.exch_get (lp, fp); +if (!ep) { +fc_frame_free (fp); +return NULL ; + } +return fc_exch_send (lp, ep, fp, resp, destructor, arg, timer_msec); +}EXPORT_SYMBOL (fc_exch_seq_send);/*
@@ -1906,6 +1917,9 @@ int fc_exch_init(struct fc_lport *lp)if (!lp->tt.seq_start_next) lp->tt.seq_start_next = fc_seq_start_next; +if (!lp->tt.exch_send) + lp->tt.exch_send = fc_exch_send; +if (!lp->tt.exch_seq_send) lp->tt.exch_seq_send = fc_exch_seq_send;
drivers/scsi/libfc/fc_fcp.c +34 -2
@@ -285,6 +285,11 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) len =fr_len (fp) -sizeof (*fh); buf =fc_frame_payload_get (fp,0 ); +/* if this I/O is ddped, update xfer len */ +if (fsp->xfer_ddp && lp->tt.ddp_done) { + fsp->xfer_len = lp->tt.ddp_done (lp, fsp->xfer_ddp); + fsp->xfer_ddp =0 ; + }if (offset + len > fsp->data_len) {/* this should never happen */ if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) &&
@@ -740,6 +745,12 @@ static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) fsp->scsi_comp_flags = flags; expected_len = fsp->data_len; +/* if ddp, update xfer len */ +if (fsp->xfer_ddp && fsp->lp->tt.ddp_done) { + fsp->xfer_len = fsp->lp->tt.ddp_done (fsp->lp, fsp->xfer_ddp); + fsp->xfer_ddp =0 ; + } +if (unlikely ((flags & ~FCP_CONF_REQ ) || fc_rp->fr_status)) { rp_ex = (void *)(fc_rp +1 );if (flags & (FCP_RSP_LEN_VAL |FCP_SNS_LEN_VAL )) {
@@ -987,6 +998,7 @@ static int fc_fcp_cmd_send(struct fc_lport *lp, struct fc_fcp_pkt *fsp, {struct fc_frame *fp;struct fc_seq *seq; +struct fc_exch *ep;struct fc_rport *rport;struct fc_rport_libfc_priv *rp;const size_t len =sizeof (fsp->cdb_cmd);
@@ -1011,7 +1023,21 @@ static int fc_fcp_cmd_send(struct fc_lport *lp, struct fc_fcp_pkt *fsp,fc_host_port_id (rp->local_port->host),FC_TYPE_FCP , FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); - seq = lp->tt.exch_seq_send (lp, fp, resp, fc_fcp_pkt_destroy, fsp,0 ); + ep = lp->tt.exch_get (lp, fp); +if (!ep) { +fc_frame_free (fp); + goto unlock; + rc =-1 ; + } + +if ((fsp->req_flags &FC_SRB_READ ) && + (lp->lro_enabled) && (lp->tt.ddp_setup)) { +if (lp->tt.ddp_setup (lp, ep->xid,scsi_sglist (fsp->cmd), +scsi_sg_count (fsp->cmd))) + fsp->xfer_ddp = ep->xid; + } + + seq = lp->tt.exch_send (lp, ep, fp, resp, fc_fcp_pkt_destroy, fsp,0 );if (!seq) {fc_frame_free (fp); rc =-1 ;
@@ -1736,6 +1762,13 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)struct fc_lport *lp;unsigned long flags; +/* release outstanding ddp context */ + lp = fsp->lp; +if (fsp->xfer_ddp && lp->tt.ddp_done) { + lp->tt.ddp_done (lp, fsp->xfer_ddp); + fsp->xfer_ddp =0 ; + } + fsp->state |=FC_SRB_COMPL ;if (!(fsp->state &FC_SRB_FCP_PROCESSING_TMO )) {spin_unlock_bh (&fsp->scsi_pkt_lock);
@@ -1743,7 +1776,6 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)spin_lock_bh (&fsp->scsi_pkt_lock); } - lp = fsp->lp; si =fc_get_scsi_internal (lp);spin_lock_irqsave (lp->host->host_lock, flags);if (!fsp->cmd) {
include/scsi/libfc.h +46 -0
64 lines not on this page · raw message
PATCH 5/7 fcoe: add support to net_fcoe_ops in fcoe_sw
In reply to a message not in the archiveThis adds implementation of ddp_setup()/ddp_done() in fcoe_sw for its fcoe_sw_libfc_fcn_templ.
---
drivers/scsi/fcoe/fcoe_sw.c | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-)
drivers/scsi/fcoe/fcoe_sw.c +37 -0
@@ -373,8 +373,45 @@ static int fcoe_sw_destroy(struct net_device *netdev)return 0 ; } +/* +* fcoe_sw_ddp_setup - calls LLD's ddp_setup through net_device +* @lp: the corresponding fc_lport +* @xid: the exchange id for this ddp transfer +* @sgl: the scatterlist describing this transfer +* @sgc: number of sg items +* +* Returns : 0 no ddp +*/ +static int fcoe_sw_ddp_setup (struct fc_lport *lp,u16 xid, +struct scatterlist *sgl,unsigned int sgc) +{ +struct net_device *ndev =fcoe_netdev (lp); + +if (ndev->fcoe_ops && ndev->fcoe_ops->ddp_setup) +return ndev->fcoe_ops->ddp_setup (ndev, xid, sgl, sgc); +return 0 ; +} + +/* +* fcoe_sw_ddp_done - calls LLD's ddp_done through net_device +* @lp: the corresponding fc_lport +* @xid: the exchange id for this ddp transfer +* +* Returns : the length of data that have been completed by ddp +*/ +static int fcoe_sw_ddp_done (struct fc_lport *lp,u16 xid) +{ +struct net_device *ndev =fcoe_netdev (lp); + +if (ndev->fcoe_ops && ndev->fcoe_ops->ddp_done) +return ndev->fcoe_ops->ddp_done (ndev, xid); +return 0 ; +} +static struct libfc_function_template fcoe_sw_libfc_fcn_templ = { .frame_send = fcoe_xmit, + .ddp_setup = fcoe_sw_ddp_setup, + .ddp_done = fcoe_sw_ddp_done, };/**
PATCH 6/7 fcoe: remove ETH_P_FCOE from fc_fcoe.h
In reply to a message not in the archiveNo need to have ETH_P_FCOE in fc_fcoe.h as it is now defined in if_ether.h
---
include/scsi/fc/fc_fcoe.h | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)
include/scsi/fc/fc_fcoe.h +0 -7
@@ -25,13 +25,6 @@*/ /* -* The FCoE ethertype eventually goes in net/if_ether.h. -*/ -#ifndef ETH_P_FCOE -#define ETH_P_FCOE 0x8906/* FCOE ether type */ -#endif - -/* * FC_FCOE_OUI hasn't been standardized yet. XXX TBD. */ #ifndef FC_FCOE_OUI
Re: [PATCH 6/7] fcoe: remove ETH_P_FCOE from fc_fcoe.h
Quoted 13 lines · On Thu, 19 Feb 2009 12:50:23 -0700 Yi Zou <[email protected]> wrote:
No need to have
ETH_P_FCOEinfc_fcoe.has it is now defined inif_ether.hSigned-off-by Yi Zou <[email protected]>---
include/scsi/fc/fc_fcoe.h | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)include/scsi/fc/fc_fcoe.h +0
-0
include/scsi/fc/fc_fcoe.h line 28
Quoted 10 lines
include/scsi/fc/fc_fcoe.h +0
-6@@ -25,13 +25,6 @@*/ /* -* The FCoE ethertype eventually goes in net/if_ether.h. -*/ -#ifndef ETH_P_FCOE -#define ETH_P_FCOE 0x8906/* FCOE ether type */ -#endif -
Just do the move from fc_fcoe.h to if_ether.h in one patch.
RE: [PATCH 6/7] fcoe: remove ETH_P_FCOE from fc_fcoe.h
Quoted 19 lines
Quoted 1 line · On Thu, 19 Feb 2009 12:50:23 -0700 Yi Zou <[email protected]> wrote:
No need to have
ETH_P_FCOEinfc_fcoe.has it is now defined in
if_ether.hQuoted 14 lines
Signed-off-by Yi Zou <[email protected]>---
include/scsi/fc/fc_fcoe.h | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)include/scsi/fc/fc_fcoe.h +0
-0@@ -25,13 +25,6 @@*/
Quoted 9 lines
include/scsi/fc/fc_fcoe.h
Quoted 8 lines
include/scsi/fc/fc_fcoe.h +0
-6/* -* The FCoE ethertype eventually goes in net/if_ether.h. -*/ -#ifndef ETH_P_FCOE -#define ETH_P_FCOE 0x8906/* FCOE ether type */ -#endif -Just do the move from
fc_fcoe.htoif_ether.hin one patch.
Good point, I'll fix that.
Thanks.
yi
PATCH 7/7 fcoe: fcoe fc crc offload indication by skb->ip_summed
In reply to a message not in the archiveIf LLD supports FCCRC offload, it should set ip_summed to be CHECKSUM_UNNECESSARY so we don't have to do CRC check again.
---
drivers/scsi/fcoe/libfcoe.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/fcoe/libfcoe.c +1 -1
@@ -624,7 +624,7 @@ int fcoe_percpu_receive_thread(void *arg)* it's solicited data, in which case, the FCP layer would * check it during the copy. */ -if (lp->crc_offload) +if (lp->crc_offload && skb->ip_summed ==CHECKSUM_UNNECESSARY )fr_flags (fp) &= ~FCPHF_CRC_UNCHECKED ;else fr_flags (fp) |=FCPHF_CRC_UNCHECKED ;