FCoE Sysfs
v3 cover FCoE Sysfs
v3: Addressed Greg KH's second set of review comments
* Created a 'fcoe bus' with the fcoe_ctlr and fcoe_fcf instances as devices on the bus. Created bus_type(s) for both device types, with default attribute group sets for each. Now sysfs core adds/removes attributes which allowed the removal of sysfs_create_group calls before device_add. Updated Documentation/ accordingly.
* Renamed structures and APIs to make them less confusing.
structs:
fcoe_ctlr_attrs -> fcoe_ctlr_device
fcoe_fcf_attrs -> fcoe_fcf_devicefunctions:
fcoe_ctlr_attrs_add -> fcoe_ctlr_device_add
fcoe_ctlr_attrs_delete -> fcoe_ctlr_device_delete
fcoe_fcf_attrs_add -> fcoe_fcf_device_add
fcoe_fcf_attrs_delete -> fcoe_fcf_device_delete* Removed extra get_device(parent) for both the fcoe_ctlr_device and fcoe_fcf_device.
* fixed 'unused variable' compilation warning that existed in v2.
* API symbols now exported with EXPORT_SYMBOL_GPL
* NOT ADDRESSED - idr usage vs. atomic incremeting of fcoe_ctlr and fcoe_fcf id enumeration. It was indicated that idr has not traditionally been used in drivers/scsi/. I will re-examine this if there is still heartburn.
---
v2: Addressed Greg KH's review comments
* moved fcoe_ctlr_attrs and fcoe_fcf_attrs attribute helper macros from fcoe_sysfs.h to fcoe_sysfs.c so that they don't temp developers to use them. They're intended to be used in attribute show/store routine generating macros, but not by drivers.
* Removed unnecessary put_device calls on parent devices. Also removed unnecessary de-initialization of pointers to parent and removed unnecessary zero'ing of memory before freeing it.
* Added Documentation/ABI/testing/sysfs-class-fcoe document.
* Changed simple_strtoul usage to kstrtoul to avoid checkpatch.pl warning that I missed before. There's a bunch of noise in checkpatch.pl due to an odd macro usage, but I think any remaining checkpatch.pl warnings are OK.
---
This patch series adds a sysfs layer to libfcoe. It adds a sysfs instance for FIP controllers (a SW entity) and discovered Fibre Channel Forwarders (FCFs), which are simply FCoE switches.
The new sysfs code is used by any driver that currently uses libfcoe, namely fcoe.ko and bnx2fc_fcoe.ko. Any other FCoE capable device that wishes to use the high-level APIs defined in fcoe_syfs.h may, without having to use the the protocol processing portions of libfcoe.
The code borrows heavily from the FC Transport, but is less complicated because it does not need to interact with the SCSI layer directly.
I think one thing to consider with this series is that drivers, such as traditional HBAs, which wish to use this infrastructure will now need to depend on libfcoe.ko. It was either this or create a superfluous kernel module; I think libfcoe is an appropriate place for this code.
This series was created against scsi-misc + 9 patches mailed by me to linux-scsi on 03/09/12. (Note that 10 patches were mailed, but that patch 01/10 will be dropped)
I'm not sure if there's somewhere I should cross-post this for general sysfs review. I don't think I'm doing anything odd; I added Greg K-H to the CC list to try and get some sysfs eyes on this code.
---
Robert Love (4):
fcoe: Allocate fcoe_ctlr with fcoe_interface, not as a member
bnx2fc: Allocate fcoe_ctlr with bnx2fc_interface, not as a member
libfcoe: Add fcoe_sysfs
fcoe, bnx2fc, libfcoe: SW FCoE and bnx2fc use FCoE Syfs
Documentation/ABI/testing/sysfs-bus-fcoe | 77 +++ drivers/scsi/bnx2fc/bnx2fc.h | 7 drivers/scsi/bnx2fc/bnx2fc_els.c | 2 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 171 +++++- drivers/scsi/bnx2fc/bnx2fc_hwi.c | 39 + drivers/scsi/fcoe/Makefile | 2 drivers/scsi/fcoe/fcoe.c | 196 +++++-- drivers/scsi/fcoe/fcoe.h | 8 drivers/scsi/fcoe/fcoe_ctlr.c | 159 +++++- drivers/scsi/fcoe/fcoe_sysfs.c | 834 ++++++++++++++++++++++++++++++ drivers/scsi/fcoe/fcoe_transport.c | 13 include/scsi/fcoe_sysfs.h | 124 ++++ include/scsi/libfcoe.h | 27 + 13 files changed, 1526 insertions(+), 133 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-fcoe create mode 100644 drivers/scsi/fcoe/fcoe_sysfs.c create mode 100644 include/scsi/fcoe_sysfs.h
Signature · 1 line
Thanks, //Rob
PATCH v3 1/4 fcoe: Allocate fcoe_ctlr with fcoe_interface, not as a member
Currently the fcoe_ctlr associated with an interface is allocated as a member of struct fcoe_interface. This causes problems when attempting to use the new fcoe_sysfs APIs which allow us to allocate the fcoe_interface as private data to the fcoe_ctlr_attrs instance. The problem is that libfcoe wants to be able use pointer math to find a fcoe_ctlr's fcoe_ctlr_attrs as well as finding a fcoe_ctlr_attrs' assocated fcoe_ctlr. To do this we need to allocate the fcoe_ctlr_attrs, with private data for the LLD. The private data contains the fcoe_ctlr and it's private data is the fcoe_interface.
+-----------------+ | fcoe_ctlr_attrs | +-----------------+ | fcoe_ctlr | +-----------------+ | fcoe_interface | +-----------------+
This prep work allows us to go from a fcoe_ctlr_attrs instance to its fcoe_ctlr and we can also go from a fcoe_ctlr to its fcoe_ctlr_attrs once the fcoe_sysfs API is in use (later patches in this series).
--- drivers/scsi/fcoe/fcoe.c | 132 ++++++++++++++++++++++++++++++---------------- drivers/scsi/fcoe/fcoe.h | 8 ++- include/scsi/libfcoe.h | 9 +++ 3 files changed, 99 insertions(+), 50 deletions(-)
drivers/scsi/fcoe/fcoe.c +85 -47
@@ -282,7 +282,7 @@ static struct scsi_host_template fcoe_shost_template = {static int fcoe_interface_setup (struct fcoe_interface *fcoe,struct net_device *netdev) { -struct fcoe_ctlr *fip = &fcoe->ctlr; +struct fcoe_ctlr *fip =fcoe_to_ctlr (fcoe);struct netdev_hw_addr *ha;struct net_device *real_dev;u8 flogi_maddr[ETH_ALEN ];
@@ -366,7 +366,9 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,static struct fcoe_interface *fcoe_interface_create (struct net_device *netdev,enum fip_state fip_mode) { +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe; +int size;int err;if (!try_module_get (THIS_MODULE )) {
@@ -376,7 +378,9 @@ static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev, goto out; } - fcoe =kzalloc (sizeof (*fcoe),GFP_KERNEL ); + size =sizeof (struct fcoe_ctlr ) +sizeof (struct fcoe_interface ); + ctlr =kzalloc (size,GFP_KERNEL ); + fcoe =fcoe_ctlr_priv (ctlr);if (!fcoe) {FCOE_NETDEV_DBG (netdev,"Could not allocate fcoe structure\n" ); fcoe =ERR_PTR (-ENOMEM );
@@ -388,15 +392,14 @@ static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,/* * Initialize FIP. */ -fcoe_ctlr_init (&fcoe->ctlr, fip_mode); - fcoe->ctlr.send = fcoe_fip_send; - fcoe->ctlr.update_mac = fcoe_update_src_mac; - fcoe->ctlr.get_src_addr = fcoe_get_src_mac; +fcoe_ctlr_init (ctlr, fip_mode); + ctlr->send = fcoe_fip_send; + ctlr->update_mac = fcoe_update_src_mac; + ctlr->get_src_addr = fcoe_get_src_mac; err =fcoe_interface_setup (fcoe, netdev);if (err) { -fcoe_ctlr_destroy (&fcoe->ctlr); -kfree (fcoe); +fcoe_ctlr_destroy (ctlr);dev_put (netdev); fcoe =ERR_PTR (err); goto out_putmod;
@@ -419,7 +422,7 @@ out:static void fcoe_interface_cleanup (struct fcoe_interface *fcoe) {struct net_device *netdev = fcoe->netdev; -struct fcoe_ctlr *fip = &fcoe->ctlr; +struct fcoe_ctlr *fip =fcoe_to_ctlr (fcoe);u8 flogi_maddr[ETH_ALEN ];const struct net_device_ops *ops;
@@ -459,7 +462,6 @@ static void fcoe_interface_cleanup(struct fcoe_interface *fcoe)/* Release the self-reference taken during fcoe_interface_create() */ /* tear-down the FCoE controller */ fcoe_ctlr_destroy (fip); -kfree (fcoe);dev_put (netdev);module_put (THIS_MODULE ); }
@@ -479,9 +481,11 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *netdev, struct net_device *orig_dev) {struct fcoe_interface *fcoe; +struct fcoe_ctlr *ctlr; fcoe = container_of(ptype, struct fcoe_interface, fip_packet_type); -fcoe_ctlr_recv (&fcoe->ctlr, skb); + ctlr =fcoe_to_ctlr (fcoe); +fcoe_ctlr_recv (ctlr, skb);return 0 ; }
@@ -633,11 +637,13 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)u32 mfs;u64 wwnn, wwpn;struct fcoe_interface *fcoe; +struct fcoe_ctlr *ctlr;struct fcoe_port *port;/* Setup lport private data to point to fcoe softc */ port =lport_priv (lport); fcoe = port->priv; + ctlr =fcoe_to_ctlr (fcoe);/* * Determine max frame size based on underlying device and optional
@@ -664,10 +670,10 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)if (!lport->vport) {if (fcoe_get_wwn (netdev, &wwnn,NETDEV_FCOE_WWNN )) - wwnn =fcoe_wwn_from_mac (fcoe->ctlr.ctl_src_addr,1 ,0 ); + wwnn =fcoe_wwn_from_mac (ctlr->ctl_src_addr,1 ,0 );fc_set_wwnn (lport, wwnn);if (fcoe_get_wwn (netdev, &wwpn,NETDEV_FCOE_WWPN )) - wwpn =fcoe_wwn_from_mac (fcoe->ctlr.ctl_src_addr, + wwpn =fcoe_wwn_from_mac (ctlr->ctl_src_addr,2 ,0 );fc_set_wwpn (lport, wwpn); }
@@ -1036,6 +1042,7 @@ static int fcoe_ddp_done(struct fc_lport *lport, u16 xid)static struct fc_lport *fcoe_if_create (struct fcoe_interface *fcoe,struct device *parent,int npiv) { +struct fcoe_ctlr *ctlr =fcoe_to_ctlr (fcoe);struct net_device *netdev = fcoe->netdev;struct fc_lport *lport, *n_port;struct fcoe_port *port;
@@ -1099,7 +1106,7 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe, }/* Initialize the library */ - rc =fcoe_libfc_config (lport, &fcoe->ctlr, &fcoe_libfc_fcn_templ,1 ); + rc =fcoe_libfc_config (lport, ctlr, &fcoe_libfc_fcn_templ,1 );if (rc) {FCOE_NETDEV_DBG (netdev,"Could not configure libfc for the " "interface\n" );
@@ -1366,6 +1373,7 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, {struct fc_lport *lport;struct fcoe_rcv_info *fr; +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe;struct fc_frame_header *fh;struct fcoe_percpu_s *fps;
@@ -1373,7 +1381,8 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,unsigned int cpu; fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type); - lport = fcoe->ctlr.lp; + ctlr =fcoe_to_ctlr (fcoe); + lport = ctlr->lp;if (unlikely (!lport)) {FCOE_NETDEV_DBG (netdev,"Cannot find hba structure" ); goto err2;
@@ -1389,8 +1398,8 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, eh =eth_hdr (skb); -if (is_fip_mode (&fcoe->ctlr) && -compare_ether_addr (eh->h_source, fcoe->ctlr.dest_addr)) { +if (is_fip_mode (ctlr) && +compare_ether_addr (eh->h_source, ctlr->dest_addr)) {FCOE_NETDEV_DBG (netdev,"wrong source mac address:%pM\n" , eh->h_source); goto err;
@@ -1524,6 +1533,7 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp)unsigned int elen;/* eth header, may include vlan */ struct fcoe_port *port =lport_priv (lport);struct fcoe_interface *fcoe = port->priv; +struct fcoe_ctlr *ctlr =fcoe_to_ctlr (fcoe);u8 sof, eof;struct fcoe_hdr *hp;
@@ -1539,7 +1549,7 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) }if (unlikely (fh->fh_type ==FC_TYPE_ELS ) && -fcoe_ctlr_els_send (&fcoe->ctlr, lport, skb)) +fcoe_ctlr_els_send (ctlr, lport, skb))return 0 ; sof =fr_sof (fp);
@@ -1603,12 +1613,12 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp)/* fill up mac and fcoe headers */ eh =eth_hdr (skb); eh->h_proto =htons (ETH_P_FCOE ); -memcpy (eh->h_dest, fcoe->ctlr.dest_addr,ETH_ALEN ); -if (fcoe->ctlr.map_dest) +memcpy (eh->h_dest, ctlr->dest_addr,ETH_ALEN ); +if (ctlr->map_dest)memcpy (eh->h_dest +3 , fh->fh_d_id,3 ); -if (unlikely (fcoe->ctlr.flogi_oxid !=FC_XID_UNKNOWN )) -memcpy (eh->h_source, fcoe->ctlr.ctl_src_addr,ETH_ALEN ); +if (unlikely (ctlr->flogi_oxid !=FC_XID_UNKNOWN )) +memcpy (eh->h_source, ctlr->ctl_src_addr,ETH_ALEN );else memcpy (eh->h_source, port->data_src_addr,ETH_ALEN );
@@ -1657,6 +1667,7 @@ static void fcoe_percpu_flush_done(struct sk_buff *skb)static inline int fcoe_filter_frames (struct fc_lport *lport,struct fc_frame *fp) { +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe;struct fc_frame_header *fh;struct sk_buff *skb = (struct sk_buff *)fp;
@@ -1678,7 +1689,8 @@ static inline int fcoe_filter_frames(struct fc_lport *lport,return 0 ; fcoe = ((struct fcoe_port *)lport_priv (lport))->priv; -if (is_fip_mode (&fcoe->ctlr) &&fc_frame_payload_op (fp) ==ELS_LOGO && + ctlr =fcoe_to_ctlr (fcoe); +if (is_fip_mode (ctlr) &&fc_frame_payload_op (fp) ==ELS_LOGO &&ntoh24 (fh->fh_s_id) ==FC_FID_FLOGI ) {FCOE_DBG ("fcoe: dropping FCoE lport LOGO in fip mode\n" );return -EINVAL ;
@@ -1857,6 +1869,7 @@ static int fcoe_dcb_app_notification(struct notifier_block *notifier, ulong event, void *ptr) { struct dcb_app_type *entry = ptr; +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe;struct net_device *netdev;struct fcoe_port *port;
@@ -1874,6 +1887,8 @@ static int fcoe_dcb_app_notification(struct notifier_block *notifier,if (!fcoe)return NOTIFY_OK ; + ctlr =fcoe_to_ctlr (fcoe); +if (entry->dcbx &DCB_CAP_DCBX_VER_CEE ) prio =ffs (entry->app.priority) -1 ;else
@@ -1884,10 +1899,10 @@ static int fcoe_dcb_app_notification(struct notifier_block *notifier,if (entry->app.protocol ==ETH_P_FIP || entry->app.protocol ==ETH_P_FCOE ) - fcoe->ctlr.priority = prio; + ctlr->priority = prio;if (entry->app.protocol ==ETH_P_FCOE ) { - port =lport_priv (fcoe->ctlr.lp); + port =lport_priv (ctlr->lp); port->priority = prio; }
@@ -1909,6 +1924,7 @@ static int fcoe_device_notification(struct notifier_block *notifier, {struct fc_lport *lport =NULL ;struct net_device *netdev = ptr; +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe;struct fcoe_port *port;struct fcoe_dev_stats *stats;
@@ -1918,7 +1934,8 @@ static int fcoe_device_notification(struct notifier_block *notifier,list_for_each_entry (fcoe, &fcoe_hostlist, list) {if (fcoe->netdev == netdev) { - lport = fcoe->ctlr.lp; + ctlr =fcoe_to_ctlr (fcoe); + lport = ctlr->lp;break ; } }
@@ -1947,7 +1964,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,break ;case NETDEV_UNREGISTER :list_del (&fcoe->list); - port =lport_priv (fcoe->ctlr.lp); + port =lport_priv (ctlr->lp);queue_work (fcoe_wq, &port->destroy_work); goto out;break ;
@@ -1962,8 +1979,8 @@ static int fcoe_device_notification(struct notifier_block *notifier,fcoe_link_speed_update (lport);if (link_possible && !fcoe_link_ok (lport)) -fcoe_ctlr_link_up (&fcoe->ctlr); -else if (fcoe_ctlr_link_down (&fcoe->ctlr)) { +fcoe_ctlr_link_up (ctlr); +else if (fcoe_ctlr_link_down (ctlr)) { stats =per_cpu_ptr (lport->dev_stats,get_cpu ()); stats->LinkFailureCount++;put_cpu ();
@@ -1983,6 +2000,7 @@ out:*/ static int fcoe_disable (struct net_device *netdev) { +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe;int rc =0 ;
@@ -1993,8 +2011,9 @@ static int fcoe_disable(struct net_device *netdev)rtnl_unlock ();if (fcoe) { -fcoe_ctlr_link_down (&fcoe->ctlr); -fcoe_clean_pending_queue (fcoe->ctlr.lp); + ctlr =fcoe_to_ctlr (fcoe); +fcoe_ctlr_link_down (ctlr); +fcoe_clean_pending_queue (ctlr->lp); }else rc = -ENODEV ;
@@ -2012,6 +2031,7 @@ static int fcoe_disable(struct net_device *netdev)*/ static int fcoe_enable (struct net_device *netdev) { +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe;int rc =0 ;
@@ -2020,11 +2040,17 @@ static int fcoe_enable(struct net_device *netdev) fcoe =fcoe_hostlist_lookup_port (netdev);rtnl_unlock (); -if (!fcoe) +if (!fcoe) { rc = -ENODEV ; -else if (!fcoe_link_ok (fcoe->ctlr.lp)) -fcoe_ctlr_link_up (&fcoe->ctlr); + goto out; + } + ctlr =fcoe_to_ctlr (fcoe); + +if (!fcoe_link_ok (ctlr->lp)) +fcoe_ctlr_link_up (ctlr); + +out:mutex_unlock (&fcoe_config_mutex);return rc; }
@@ -2039,6 +2065,7 @@ static int fcoe_enable(struct net_device *netdev)*/ static int fcoe_destroy (struct net_device *netdev) { +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe;struct fc_lport *lport;struct fcoe_port *port;
@@ -2051,7 +2078,8 @@ static int fcoe_destroy(struct net_device *netdev) rc = -ENODEV ; goto out_nodev; } - lport = fcoe->ctlr.lp; + ctlr =fcoe_to_ctlr (fcoe); + lport = ctlr->lp; port =lport_priv (lport);list_del (&fcoe->list);queue_work (fcoe_wq, &port->destroy_work);
@@ -2106,7 +2134,8 @@ static void fcoe_dcb_create(struct fcoe_interface *fcoe)int dcbx;u8 fup, up;struct net_device *netdev = fcoe->realdev; -struct fcoe_port *port =lport_priv (fcoe->ctlr.lp); +struct fcoe_ctlr *ctlr =fcoe_to_ctlr (fcoe); +struct fcoe_port *port =lport_priv (ctlr->lp);struct dcb_app app = { .priority =0 , .protocol =ETH_P_FCOE
@@ -2129,7 +2158,7 @@ static void fcoe_dcb_create(struct fcoe_interface *fcoe) } port->priority =ffs (up) ?ffs (up) -1 :0 ; - fcoe->ctlr.priority =ffs (fup) ?ffs (fup) -1 : port->priority; + ctlr->priority =ffs (fup) ?ffs (fup) -1 : port->priority; }#endif }
@@ -2146,6 +2175,7 @@ static void fcoe_dcb_create(struct fcoe_interface *fcoe)static int fcoe_create (struct net_device *netdev,enum fip_state fip_mode) {int rc =0 ; +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe;struct fc_lport *lport;
@@ -2164,6 +2194,8 @@ static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode) goto out_nodev; } + ctlr =fcoe_to_ctlr (fcoe); + lport =fcoe_if_create (fcoe, &netdev->dev,0 );if (IS_ERR (lport)) { printk(KERN_ERR "fcoe: Failed to create interface (%s)\n",
@@ -2175,7 +2207,7 @@ static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode) }/* Make this the "master" N_Port */ - fcoe->ctlr.lp = lport; + ctlr->lp = lport;/* setup DCB priority attributes. */ fcoe_dcb_create (fcoe);
@@ -2187,7 +2219,7 @@ static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode) lport->boot_time = jiffies;fc_fabric_login (lport);if (!fcoe_link_ok (lport)) -fcoe_ctlr_link_up (&fcoe->ctlr); +fcoe_ctlr_link_up (ctlr); out_nodev:rtnl_unlock ();
@@ -2297,11 +2329,12 @@ static int fcoe_reset(struct Scsi_Host *shost)struct fc_lport *lport =shost_priv (shost);struct fcoe_port *port =lport_priv (lport);struct fcoe_interface *fcoe = port->priv; +struct fcoe_ctlr *ctlr =fcoe_to_ctlr (fcoe); -fcoe_ctlr_link_down (&fcoe->ctlr); -fcoe_clean_pending_queue (fcoe->ctlr.lp); -if (!fcoe_link_ok (fcoe->ctlr.lp)) -fcoe_ctlr_link_up (&fcoe->ctlr); +fcoe_ctlr_link_down (ctlr); +fcoe_clean_pending_queue (ctlr->lp); +if (!fcoe_link_ok (ctlr->lp)) +fcoe_ctlr_link_up (ctlr);return 0 ; }
@@ -2336,10 +2369,12 @@ fcoe_hostlist_lookup_port(const struct net_device *netdev)*/ static struct fc_lport *fcoe_hostlist_lookup (const struct net_device *netdev) { +struct fcoe_ctlr *ctlr;struct fcoe_interface *fcoe; fcoe =fcoe_hostlist_lookup_port (netdev); -return (fcoe) ? fcoe->ctlr.lp :NULL ; + ctlr =fcoe_to_ctlr (fcoe); +return (fcoe) ? ctlr->lp :NULL ; }/**
@@ -2443,6 +2478,7 @@ module_init(fcoe_init); static void __exit fcoe_exit(void) {struct fcoe_interface *fcoe, *tmp; +struct fcoe_ctlr *ctlr;struct fcoe_port *port;unsigned int cpu;
@@ -2454,7 +2490,8 @@ static void __exit fcoe_exit(void)rtnl_lock ();list_for_each_entry_safe (fcoe, tmp, &fcoe_hostlist, list) {list_del (&fcoe->list); - port =lport_priv (fcoe->ctlr.lp); + ctlr =fcoe_to_ctlr (fcoe); + port =lport_priv (ctlr->lp);queue_work (fcoe_wq, &port->destroy_work); }rtnl_unlock ();
@@ -2550,7 +2587,7 @@ static struct fc_seq *fcoe_elsct_send(struct fc_lport *lport, u32 did, {struct fcoe_port *port =lport_priv (lport);struct fcoe_interface *fcoe = port->priv; -struct fcoe_ctlr *fip = &fcoe->ctlr; +struct fcoe_ctlr *fip =fcoe_to_ctlr (fcoe);struct fc_frame_header *fh =fc_frame_header_get (fp);switch (op) {
@@ -2724,7 +2761,8 @@ static void fcoe_set_port_id(struct fc_lport *lport, {struct fcoe_port *port =lport_priv (lport);struct fcoe_interface *fcoe = port->priv; +struct fcoe_ctlr *ctlr =fcoe_to_ctlr (fcoe);if (fp &&fc_frame_payload_op (fp) ==ELS_FLOGI ) -fcoe_ctlr_recv_flogi (&fcoe->ctlr, lport, fp); +fcoe_ctlr_recv_flogi (ctlr, lport, fp); }
drivers/scsi/fcoe/fcoe.h +5 -3
@@ -68,7 +68,6 @@ do { \* @netdev: The associated net device * @fcoe_packet_type: FCoE packet type * @fip_packet_type: FIP packet type -* @ctlr: The FCoE controller (for FIP) * @oem: The offload exchange manager for all local port * instances associated with this port * This structure is 1:1 with a net devive.
@@ -79,11 +78,14 @@ struct fcoe_interface {struct net_device *realdev;struct packet_type fcoe_packet_type;struct packet_type fip_packet_type; -struct fcoe_ctlr ctlr;struct fc_exch_mgr *oem; }; -#define fcoe_from_ctlr (fip) container_of(fip, struct fcoe_interface, ctlr) +#define fcoe_to_ctlr (x) \ + (struct fcoe_ctlr *)(((struct fcoe_ctlr *)(x)) - 1) + +#define fcoe_from_ctlr (x) \ + ((struct fcoe_interface *)((x) + 1))/** * fcoe_netdev() - Return the net device associated with a local port
include/scsi/libfcoe.h +9 -0
@@ -159,6 +159,15 @@ struct fcoe_ctlr { };/** +* fcoe_ctlr_priv() - Return the private data from a fcoe_ctlr +* @cltr: The fcoe_ctlr whose private data will be returned +*/ +static inline void *fcoe_ctlr_priv (const struct fcoe_ctlr *ctlr) +{ +return (void *)(ctlr +1 ); +} + +/** * struct fcoe_fcf - Fibre-Channel Forwarder * @list: list linkage * @time: system time (jiffies) when an advertisement was last received
PATCH v3 2/4 bnx2fc: Allocate fcoe_ctlr with bnx2fc_interface, not as a member
In reply to Robert LoveCurrently the fcoe_ctlr associated with an interface is allocated
as a member of struct bnx2fc_interface. This causes problems when attempting to use the new fcoe_sysfs APIs which allow us to allocate the bnx2fc_interface as private data to the fcoe_ctlr_attrs instance. The problem is that libfcoe wants to be able use pointer math to find a fcoe_ctlr's fcoe_ctlr_attrs as well as finding a fcoe_ctlr_attrs' assocated fcoe_ctlr. To do this we need to allocate the fcoe_ctlr_attrs, with private data for the LLD. The private data contains the fcoe_ctlr and it's private data is the bnx2fc_interface.
+------------------+
| fcoe_ctlr_attrs |
+------------------+
| fcoe_ctlr |
+------------------+
| bnx2fc_interface |
+------------------+
This prep work allows us to go from a fcoe_ctlr_attrs instance to its fcoe_ctlr and we can also go from a fcoe_ctlr to its fcoe_ctlr_attrs once the fcoe_sysfs API is in use (later patches in this series).
--- drivers/scsi/bnx2fc/bnx2fc.h | 7 ++ drivers/scsi/bnx2fc/bnx2fc_els.c | 2 - drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 116 ++++++++++++++++++++++++------------- drivers/scsi/bnx2fc/bnx2fc_hwi.c | 39 +++++++----- 4 files changed, 101 insertions(+), 63 deletions(-)
drivers/scsi/bnx2fc/bnx2fc.h +5 -2
@@ -228,13 +228,16 @@ struct bnx2fc_interface {struct packet_type fip_packet_type;struct workqueue_struct *timer_work_queue;struct kref kref; -struct fcoe_ctlr ctlr;u8 vlan_enabled;int vlan_id;bool enabled; }; -#define bnx2fc_from_ctlr (fip) container_of(fip, struct bnx2fc_interface, ctlr) +#define bnx2fc_from_ctlr (x) \ + ((struct bnx2fc_interface *)((x) + 1)) + +#define bnx2fc_to_ctlr (x) \ + ((struct fcoe_ctlr *)(((struct fcoe_ctlr *)(x)) - 1))struct bnx2fc_lport {struct list_head list;
drivers/scsi/bnx2fc/bnx2fc_els.c +1 -1
@@ -910,7 +910,7 @@ struct fc_seq *bnx2fc_elsct_send(struct fc_lport *lport, u32 did, {struct fcoe_port *port =lport_priv (lport);struct bnx2fc_interface *interface = port->priv; -struct fcoe_ctlr *fip = &interface->ctlr; +struct fcoe_ctlr *fip =bnx2fc_to_ctlr (interface);struct fc_frame_header *fh =fc_frame_header_get (fp);switch (op) {
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +74 -42
397 lines not on this page · raw message
drivers/scsi/bnx2fc/bnx2fc_hwi.c +21 -18
@@ -167,6 +167,7 @@ int bnx2fc_send_session_ofld_req(struct fcoe_port *port, {struct fc_lport *lport = port->lport;struct bnx2fc_interface *interface = port->priv; +struct fcoe_ctlr *ctlr =bnx2fc_to_ctlr (interface);struct bnx2fc_hba *hba = interface->hba;struct kwqe *kwqe_arr[4 ];struct fcoe_kwqe_conn_offload1 ofld_req1;
@@ -314,13 +315,13 @@ int bnx2fc_send_session_ofld_req(struct fcoe_port *port, ofld_req4.src_mac_addr_mid[1 ] = port->data_src_addr[2 ]; ofld_req4.src_mac_addr_hi[0 ] = port->data_src_addr[1 ]; ofld_req4.src_mac_addr_hi[1 ] = port->data_src_addr[0 ]; - ofld_req4.dst_mac_addr_lo[0 ] = interface->ctlr.dest_addr[5 ]; + ofld_req4.dst_mac_addr_lo[0 ] = ctlr->dest_addr[5 ];/* fcf mac */ - ofld_req4.dst_mac_addr_lo[1 ] = interface->ctlr.dest_addr[4 ]; - ofld_req4.dst_mac_addr_mid[0 ] = interface->ctlr.dest_addr[3 ]; - ofld_req4.dst_mac_addr_mid[1 ] = interface->ctlr.dest_addr[2 ]; - ofld_req4.dst_mac_addr_hi[0 ] = interface->ctlr.dest_addr[1 ]; - ofld_req4.dst_mac_addr_hi[1 ] = interface->ctlr.dest_addr[0 ]; + ofld_req4.dst_mac_addr_lo[1 ] = ctlr->dest_addr[4 ]; + ofld_req4.dst_mac_addr_mid[0 ] = ctlr->dest_addr[3 ]; + ofld_req4.dst_mac_addr_mid[1 ] = ctlr->dest_addr[2 ]; + ofld_req4.dst_mac_addr_hi[0 ] = ctlr->dest_addr[1 ]; + ofld_req4.dst_mac_addr_hi[1 ] = ctlr->dest_addr[0 ]; ofld_req4.lcq_addr_lo = (u32 ) tgt->lcq_dma; ofld_req4.lcq_addr_hi = (u32)((u64 ) tgt->lcq_dma >>32 );
@@ -351,6 +352,7 @@ static int bnx2fc_send_session_enable_req(struct fcoe_port *port, {struct kwqe *kwqe_arr[2 ];struct bnx2fc_interface *interface = port->priv; +struct fcoe_ctlr *ctlr =bnx2fc_to_ctlr (interface);struct bnx2fc_hba *hba = interface->hba;struct fcoe_kwqe_conn_enable_disable enbl_req;struct fc_lport *lport = port->lport;
@@ -374,12 +376,12 @@ static int bnx2fc_send_session_enable_req(struct fcoe_port *port, enbl_req.src_mac_addr_hi[1 ] = port->data_src_addr[0 ];memcpy (tgt->src_addr, port->data_src_addr,ETH_ALEN ); - enbl_req.dst_mac_addr_lo[0 ] = interface->ctlr.dest_addr[5 ]; - enbl_req.dst_mac_addr_lo[1 ] = interface->ctlr.dest_addr[4 ]; - enbl_req.dst_mac_addr_mid[0 ] = interface->ctlr.dest_addr[3 ]; - enbl_req.dst_mac_addr_mid[1 ] = interface->ctlr.dest_addr[2 ]; - enbl_req.dst_mac_addr_hi[0 ] = interface->ctlr.dest_addr[1 ]; - enbl_req.dst_mac_addr_hi[1 ] = interface->ctlr.dest_addr[0 ]; + enbl_req.dst_mac_addr_lo[0 ] = ctlr->dest_addr[5 ]; + enbl_req.dst_mac_addr_lo[1 ] = ctlr->dest_addr[4 ]; + enbl_req.dst_mac_addr_mid[0 ] = ctlr->dest_addr[3 ]; + enbl_req.dst_mac_addr_mid[1 ] = ctlr->dest_addr[2 ]; + enbl_req.dst_mac_addr_hi[0 ] = ctlr->dest_addr[1 ]; + enbl_req.dst_mac_addr_hi[1 ] = ctlr->dest_addr[0 ]; port_id =fc_host_port_id (lport->host);if (port_id != tgt->sid) {
@@ -419,6 +421,7 @@ int bnx2fc_send_session_disable_req(struct fcoe_port *port, struct bnx2fc_rport *tgt) {struct bnx2fc_interface *interface = port->priv; +struct fcoe_ctlr *ctlr =bnx2fc_to_ctlr (interface);struct bnx2fc_hba *hba = interface->hba;struct fcoe_kwqe_conn_enable_disable disable_req;struct kwqe *kwqe_arr[2 ];
@@ -440,12 +443,12 @@ int bnx2fc_send_session_disable_req(struct fcoe_port *port, disable_req.src_mac_addr_hi[0 ] = tgt->src_addr[1 ]; disable_req.src_mac_addr_hi[1 ] = tgt->src_addr[0 ]; - disable_req.dst_mac_addr_lo[0 ] = interface->ctlr.dest_addr[5 ]; - disable_req.dst_mac_addr_lo[1 ] = interface->ctlr.dest_addr[4 ]; - disable_req.dst_mac_addr_mid[0 ] = interface->ctlr.dest_addr[3 ]; - disable_req.dst_mac_addr_mid[1 ] = interface->ctlr.dest_addr[2 ]; - disable_req.dst_mac_addr_hi[0 ] = interface->ctlr.dest_addr[1 ]; - disable_req.dst_mac_addr_hi[1 ] = interface->ctlr.dest_addr[0 ]; + disable_req.dst_mac_addr_lo[0 ] = ctlr->dest_addr[5 ]; + disable_req.dst_mac_addr_lo[1 ] = ctlr->dest_addr[4 ]; + disable_req.dst_mac_addr_mid[0 ] = ctlr->dest_addr[3 ]; + disable_req.dst_mac_addr_mid[1 ] = ctlr->dest_addr[2 ]; + disable_req.dst_mac_addr_hi[0 ] = ctlr->dest_addr[1 ]; + disable_req.dst_mac_addr_hi[1 ] = ctlr->dest_addr[0 ]; port_id = tgt->sid; disable_req.s_id[0 ] = (port_id &0x000000FF );
PATCH v3 3/4 libfcoe: Add fcoe_sysfs
In reply to Robert LoveThis patch adds a 'fcoe bus' infrastructure to the kernel that is driven by changes to libfcoe which allow LLDs to present FIP (FCoE Initialization Protocol) discovered entities and their attributes to user space via sysfs.
This patch adds the following APIs-
fcoe_ctlr_device_addfcoe_ctlr_device_deletefcoe_fcf_device_addfcoe_fcf_device_delete
They allow the LLD to expose the FCoE ENode Controller and any discovered FCFs (Fibre Channel Forwarders, e.g. FCoE switches) to the user. Each of these new devices has their own bus_type so that they are grouped together for easy lookup from a user space application. Each new class has an attribute_group to expose attributes for any created instances. The attributes are-
fcoe_ctlr_device
* fcf_dev_loss_tmo
* lesb_link_fail
* lesb_vlink_fail
* lesb_miss_fka
* lesb_symb_err
* lesb_err_block
* lesb_fcs_error
fcoe_fcf_device
* fabric_name
* switch_name
* priority
* selected
* fc_map
* vfid
* mac
* fka_peroid
* fabric_state
* dev_loss_tmo
A device loss infrastructre similar to the FC Transport's is also added by this patch. It is nice to have so that a link flapping adapter doesn't continually advance the count used to identify the discovered FCF. FCFs will exist in a "Disconnected" state until either the timer expires or the FCF is rediscovered and becomes "Connected."
This patch generates a few checkpatch.pl WARNINGS that I'm not sure what to do about. They're macros modeled around the FC Transport attribute building macros, which have the same 'feature' where the caller can ommit a cast in the argument list and no cast occurs in the code. I'm not sure how to keep the code condensed while keeping the macros. Any advice would be appreciated.
--- Documentation/ABI/testing/sysfs-bus-fcoe | 77 +++ drivers/scsi/fcoe/Makefile | 2 drivers/scsi/fcoe/fcoe_sysfs.c | 834 ++++++++++++++++++++++++++++++ drivers/scsi/fcoe/fcoe_transport.c | 13 include/scsi/fcoe_sysfs.h | 124 ++++ include/scsi/libfcoe.h | 1 6 files changed, 1048 insertions(+), 3 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-fcoe create mode 100644 drivers/scsi/fcoe/fcoe_sysfs.c create mode 100644 include/scsi/fcoe_sysfs.h
Documentation/ABI/testing/sysfs-bus-fcoe new file +77 -0
@@ -0,0 +1,77 @@ +What: /sys/bus/fcoe/ctlr_X +Date: March 2012 +KernelVersion: TBD +Contact: Robert Love <[email protected]>, [email protected] +Description: 'FCoE Controller' instances on the fcoe bus +Attributes: + + fcf_dev_loss_tmo: Device loss timeout peroid (see below). Changing + this value will change the dev_loss_tmo for all + FCFs discovered by this controller. + + lesb_link_fail: Link Error Status Block (LESB) link failure count. + + lesb_vlink_fail: Link Error Status Block (LESB) virtual link + failure count. + + lesb_miss_fka: Link Error Status Block (LESB) missed FCoE + Initialization Protocol (FIP) Keep-Alives (FKA). + + lesb_symb_err: Link Error Status Block (LESB) symbolic error count. + + lesb_err_block: Link Error Status Block (LESB) block error count. + + lesb_fcs_error: Link Error Status Block (LESB) Fibre Channel + Serivces error count. + +Notes: ctlr_X (global increment starting at 0) + +What: /sys/bus/fcoe/fcf_X +Date: March 2012 +KernelVersion: TBD +Contact: Robert Love <[email protected]>, [email protected] +Description: 'FCoE FCF' instances on the fcoe bus. A FCF is a Fibre Channel + Forwarder, which is a FCoE switch that can accept FCoE + (Ethernet) packets, unpack them, and forward the embedded + Fibre Channel frames into a FC fabric. It can also take + outbound FC frames and pack them in Ethernet packets to + be sent to their destination on the Ethernet segment. +Attributes: + + fabric_name: Identifies the fabric that the FCF services. + + switch_name: Identifies the FCF. + + priority: The switch's priority amongst other FCFs on the same + fabric. + + selected: 1 indicates that the switch has been selected for use; + 0 indicates that the swich will not be used. + + fc_map: The Fibre Channel MAP + + vfid: The Virtual Fabric ID + + mac: The FCF's MAC address + + fka_peroid: The FIP Keep-Alive peroid + + fabric_state: The internal kernel state + "Unknown" - Initialization value + "Disconnected" - No link to the FCF/fabric + "Connected" - Host is connected to the FCF + "Deleted" - FCF is being removed from the system + + dev_loss_tmo: The device loss timeout peroid for this FCF. + +Notes: A device loss infrastructre similar to the FC Transport's + is present in fcoe_sysfs. It is nice to have so that a + link flapping adapter doesn't continually advance the count + used to identify the discovered FCF. FCFs will exist in a + "Disconnected" state until either the timer expires and the + FCF becomes "Deleted" or the FCF is rediscovered and becomes + "Connected." + + +Users: The first user of this interface will be the fcoeadm application, + which is commonly packaged in the fcoe-utils package.
drivers/scsi/fcoe/Makefile +1 -1
@@ -1,4 +1,4 @@ obj-$(CONFIG_FCOE) += fcoe.o obj-$(CONFIG_LIBFCOE) += libfcoe.o -libfcoe-objs := fcoe_ctlr.o fcoe_transport.o +libfcoe-objs := fcoe_ctlr.o fcoe_transport.o fcoe_sysfs.o
drivers/scsi/fcoe/fcoe_sysfs.c new file +834 -0
834 lines not on this page · raw message
drivers/scsi/fcoe/fcoe_transport.c +11 -2
@@ -816,9 +816,17 @@ out_nodev:*/ static int __init libfcoe_init (void ) { -fcoe_transport_init (); +int rc =0 ; -return 0 ; + rc =fcoe_transport_init (); +if (rc) +return rc; + + rc =fcoe_sysfs_setup (); +if (rc) +fcoe_transport_exit (); + +return rc; }module_init (libfcoe_init);
@@ -827,6 +835,7 @@ module_init(libfcoe_init);*/ static void __exit libfcoe_exit(void) { +fcoe_sysfs_teardown ();fcoe_transport_exit (); }module_exit (libfcoe_exit);
include/scsi/fcoe_sysfs.h new file +124 -0
124 lines not on this page · raw message
include/scsi/libfcoe.h +1 -0
@@ -29,6 +29,7 @@#include <linux/random.h> #include <scsi/fc/fc_fcoe.h> #include <scsi/libfc.h> +#include <scsi/fcoe_sysfs.h> #define FCOE_MAX_CMD_LEN 16/* Supported CDB length */
PATCH v3 4/4 fcoe, bnx2fc, libfcoe: SW FCoE and bnx2fc use FCoE Syfs
In reply to Robert LoveThis patch has the SW FCoE driver and the bnx2fc driver make use of the new fcoe_sysfs API added earlier in this patch series.
After this patch a fcoe_ctlr_device is allocated with private data in this order.
+------------------+ +------------------+ | fcoe_ctlr_device | | fcoe_ctlr_device | +------------------+ +------------------+ | fcoe_ctlr | | fcoe_ctlr | +------------------+ +------------------+ | fcoe_interface | | bnx2fc_interface | +------------------+ +------------------+
libfcoe also takes part in this new model since it discovers and manages fcoe_fcf instances. The memory allocation is different for FCFs. I didn't want to impact libfcoe's fcoe_fcf processing, so this patch creates fcoe_fcf_device instances for each discovered fcoe_fcf. The two are paired using a (void * priv) member of the fcoe_ctlr_device. This allows libfcoe to continue maintaining its list of fcoe_fcf instances and simply attaches and detaches them from existing or new fcoe_fcf_device instances.
--- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 63 ++++++++++++++- drivers/scsi/fcoe/fcoe.c | 70 +++++++++++++++- drivers/scsi/fcoe/fcoe_ctlr.c | 159 ++++++++++++++++++++++++++++++++++--- include/scsi/libfcoe.h | 17 ++++ 4 files changed, 285 insertions(+), 24 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_fcoe.c +59 -4
@@ -54,6 +54,7 @@ static struct cnic_ulp_ops bnx2fc_cnic_cb;static struct libfc_function_template bnx2fc_libfc_fcn_templ;static struct scsi_host_template bnx2fc_shost_template;static struct fc_function_template bnx2fc_transport_function; +static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ;static struct fc_function_template bnx2fc_vport_xport_function;static int bnx2fc_create (struct net_device *netdev,enum fip_state fip_mode);static void __bnx2fc_destroy (struct bnx2fc_interface *interface);
@@ -88,6 +89,7 @@ static void bnx2fc_port_shutdown(struct fc_lport *lport);static void bnx2fc_stop (struct bnx2fc_interface *interface);static int __init bnx2fc_mod_init (void ); static void __exit bnx2fc_mod_exit(void); +static void bnx2fc_ctlr_get_lesb (struct fcoe_ctlr_device *ctlr_dev);unsigned int bnx2fc_debug_level;module_param_named (debug_logging, bnx2fc_debug_level, int,S_IRUGO |S_IWUSR );
@@ -118,6 +120,41 @@ static void bnx2fc_get_lesb(struct fc_lport *lport,__fcoe_get_lesb (lport, fc_lesb, netdev); } +static void bnx2fc_ctlr_get_lesb (struct fcoe_ctlr_device *ctlr_dev) +{ +struct fcoe_ctlr *fip =fcoe_ctlr_device_priv (ctlr_dev); +struct net_device *netdev =bnx2fc_netdev (fip->lp); +struct fcoe_fc_els_lesb *fcoe_lesb; +struct fc_els_lesb fc_lesb; + +__fcoe_get_lesb (fip->lp, &fc_lesb, netdev); + fcoe_lesb = (struct fcoe_fc_els_lesb *)(&fc_lesb); + + ctlr_dev->lesb.lesb_link_fail = +ntohl (fcoe_lesb->lesb_link_fail); + ctlr_dev->lesb.lesb_vlink_fail = +ntohl (fcoe_lesb->lesb_vlink_fail); + ctlr_dev->lesb.lesb_miss_fka = +ntohl (fcoe_lesb->lesb_miss_fka); + ctlr_dev->lesb.lesb_symb_err = +ntohl (fcoe_lesb->lesb_symb_err); + ctlr_dev->lesb.lesb_err_block = +ntohl (fcoe_lesb->lesb_err_block); + ctlr_dev->lesb.lesb_fcs_error = +ntohl (fcoe_lesb->lesb_fcs_error); +} +EXPORT_SYMBOL (bnx2fc_ctlr_get_lesb); + +static void bnx2fc_fcf_get_vlan_id (struct fcoe_fcf_device *fcf_dev) +{ +struct fcoe_ctlr_device *ctlr_dev = +fcoe_fcf_dev_to_ctlr_dev (fcf_dev); +struct fcoe_ctlr *ctlr =fcoe_ctlr_device_priv (ctlr_dev); +struct bnx2fc_interface *fcoe =fcoe_ctlr_priv (ctlr); + + fcf_dev->vlan_id = fcoe->vlan_id; +} +static void bnx2fc_clean_rx_queue (struct fc_lport *lp) {struct fcoe_percpu_s *bg;
@@ -1236,6 +1273,7 @@ static void bnx2fc_release_transport(void)static void bnx2fc_interface_release (struct kref *kref) { +struct fcoe_ctlr_device *ctlr_dev;struct bnx2fc_interface *interface;struct fcoe_ctlr *ctlr;struct net_device *netdev;
@@ -1244,13 +1282,14 @@ static void bnx2fc_interface_release(struct kref *kref)BNX2FC_MISC_DBG ("Interface is being released\n" ); ctlr =bnx2fc_to_ctlr (interface); + ctlr_dev =fcoe_ctlr_to_ctlr_dev (ctlr); netdev = interface->netdev;/* tear-down FIP controller */ if (test_and_clear_bit (BNX2FC_CTLR_INIT_DONE , &interface->if_flags))fcoe_ctlr_destroy (ctlr); -kfree (ctlr); +fcoe_ctlr_device_delete (ctlr_dev);dev_put (netdev);module_put (THIS_MODULE );
@@ -1343,17 +1382,20 @@ struct bnx2fc_interface *bnx2fc_interface_create(struct bnx2fc_hba *hba,struct net_device *netdev, enum fip_state fip_mode) { + struct fcoe_ctlr_device *ctlr_dev;struct bnx2fc_interface *interface;struct fcoe_ctlr *ctlr;int size;int rc =0 ; size = (sizeof (*interface) +sizeof (struct fcoe_ctlr )); - ctlr =kzalloc (size,GFP_KERNEL ); -if (!ctlr) { + ctlr_dev =fcoe_ctlr_device_add (&netdev->dev, &bnx2fc_fcoe_sysfs_templ, + size); +if (!ctlr_dev) { printk(KERN_ERR PFX "Unable to allocate interface structure\n");return NULL ; } + ctlr =fcoe_ctlr_device_priv (ctlr_dev); interface =fcoe_ctlr_priv (ctlr);dev_hold (netdev);kref_init (&interface->kref);
@@ -1373,7 +1415,7 @@ struct bnx2fc_interface *bnx2fc_interface_create(struct bnx2fc_hba *hba,fcoe_ctlr_destroy (ctlr);dev_put (netdev); -kfree (ctlr); +fcoe_ctlr_device_delete (ctlr_dev);return NULL ; }
@@ -2472,6 +2514,19 @@ static void __exit bnx2fc_mod_exit(void)module_init (bnx2fc_mod_init);module_exit (bnx2fc_mod_exit); +static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ = { + .get_fcoe_ctlr_mode = fcoe_ctlr_get_fip_mode, + .get_fcoe_ctlr_link_fail = bnx2fc_ctlr_get_lesb, + .get_fcoe_ctlr_vlink_fail = bnx2fc_ctlr_get_lesb, + .get_fcoe_ctlr_miss_fka = bnx2fc_ctlr_get_lesb, + .get_fcoe_ctlr_symb_err = bnx2fc_ctlr_get_lesb, + .get_fcoe_ctlr_err_block = bnx2fc_ctlr_get_lesb, + .get_fcoe_ctlr_fcs_error = bnx2fc_ctlr_get_lesb, + + .get_fcoe_fcf_selected = fcoe_fcf_get_selected, + .get_fcoe_fcf_vlan_id = bnx2fc_fcf_get_vlan_id, +}; +static struct fc_function_template bnx2fc_transport_function = { .show_host_node_name =1 , .show_host_port_name =1 ,
drivers/scsi/fcoe/fcoe.c +64 -6
134 lines not on this page · raw message
drivers/scsi/fcoe/fcoe_ctlr.c +145 -14
241 lines not on this page · raw message
include/scsi/libfcoe.h +17 -0
@@ -168,9 +168,16 @@ static inline void *fcoe_ctlr_priv(const struct fcoe_ctlr *ctlr)return (void *)(ctlr +1 ); } +#define fcoe_ctlr_to_ctlr_dev (x) \ + (struct fcoe_ctlr_device *)(((struct fcoe_ctlr_device *)(x)) - 1) +/** * struct fcoe_fcf - Fibre-Channel Forwarder * @list: list linkage +* @event_work: Work for FC Transport actions queue +* @event: The event to be processed +* @fip: The controller that the FCF was discovered on +* @fcf_dev: The associated fcoe_fcf_device instance * @time: system time (jiffies) when an advertisement was last received * @switch_name: WWN of switch from advertisement * @fabric_name: WWN of fabric from advertisement
@@ -192,6 +199,9 @@ static inline void *fcoe_ctlr_priv(const struct fcoe_ctlr *ctlr)*/ struct fcoe_fcf {struct list_head list; +struct work_struct event_work; +struct fcoe_ctlr *fip; +struct fcoe_fcf_device *fcf_dev;unsigned long time;u64 switch_name;
@@ -208,6 +218,9 @@ struct fcoe_fcf { u8 fd_flags:1; }; +#define fcoe_fcf_to_fcf_dev (x) \ + ((x)->fcf_dev) +/** * struct fcoe_rport - VN2VN remote port * @time: time of create or last beacon packet received from node
@@ -343,6 +356,10 @@ void fcoe_queue_timer(ulong lport);int fcoe_get_paged_crc_eof (struct sk_buff *skb,int tlen,struct fcoe_percpu_s *fps); +/* FCoE Sysfs helpers */ +void fcoe_fcf_get_selected (struct fcoe_fcf_device *); +void fcoe_ctlr_get_fip_mode (struct fcoe_ctlr_device *); +/** * struct netdev_list * A mapping from netdevice to fcoe_transport
Quoted 1 line · Robert Love
v3: Addressed Greg KH's second set of review comments
Looks great to me, thanks for reworking all of this: