The network interface needs to be shared between all NPIV VN_Ports, therefor
it should be tracked in the fcoe_interface and not for each SCSI host in
fcoe_port.

Signed-off-by: Chris Leech <[email protected]>
---

 drivers/scsi/fcoe/fcoe.c |   85 +++++++++++++++++++++++++---------------------
 drivers/scsi/fcoe/fcoe.h |   11 +++---
 2 files changed, 51 insertions(+), 45 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 3c18f2f..392061f 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -160,7 +160,7 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct 
net_device *dev,
  */
 static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
 {
-       skb->dev = fcoe_from_ctlr(fip)->real_dev;
+       skb->dev = fcoe_from_ctlr(fip)->fcoe->real_dev;
        dev_queue_xmit(skb);
 }
 
@@ -175,13 +175,16 @@ static void fcoe_fip_send(struct fcoe_ctlr *fip, struct 
sk_buff *skb)
  */
 static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new)
 {
+       struct fcoe_interface *fcoe;
        struct fcoe_port *port;
 
        port = fcoe_from_ctlr(fip);
+       fcoe = port->fcoe;
+
        rtnl_lock();
        if (!is_zero_ether_addr(old))
-               dev_unicast_delete(port->real_dev, old);
-       dev_unicast_add(port->real_dev, new);
+               dev_unicast_delete(fcoe->real_dev, old);
+       dev_unicast_add(fcoe->real_dev, new);
        rtnl_unlock();
 }
 
@@ -224,6 +227,7 @@ static int fcoe_lport_config(struct fc_lport *lp)
 void fcoe_netdev_cleanup(struct fcoe_port *port)
 {
        u8 flogi_maddr[ETH_ALEN];
+       struct fcoe_interface *fcoe = port->fcoe;
 
        /* Don't listen for Ethernet packets anymore */
        dev_remove_pack(&port->fcoe_packet_type);
@@ -232,12 +236,12 @@ void fcoe_netdev_cleanup(struct fcoe_port *port)
        /* Delete secondary MAC addresses */
        rtnl_lock();
        memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
-       dev_unicast_delete(port->real_dev, flogi_maddr);
+       dev_unicast_delete(fcoe->real_dev, flogi_maddr);
        if (!is_zero_ether_addr(port->ctlr.data_src_addr))
-               dev_unicast_delete(port->real_dev, port->ctlr.data_src_addr);
+               dev_unicast_delete(fcoe->real_dev, port->ctlr.data_src_addr);
        if (port->ctlr.spma)
-               dev_unicast_delete(port->real_dev, port->ctlr.ctl_src_addr);
-       dev_mc_delete(port->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
+               dev_unicast_delete(fcoe->real_dev, port->ctlr.ctl_src_addr);
+       dev_mc_delete(fcoe->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
        rtnl_unlock();
 }
 
@@ -266,24 +270,26 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct 
net_device *netdev)
 {
        u32 mfs;
        u64 wwnn, wwpn;
+       struct fcoe_interface *fcoe;
        struct fcoe_port *port;
        u8 flogi_maddr[ETH_ALEN];
        struct netdev_hw_addr *ha;
 
        /* Setup lport private data to point to fcoe softc */
        port = lport_priv(lp);
+       fcoe = port->fcoe;
        port->ctlr.lp = lp;
-       port->real_dev = netdev;
-       port->phys_dev = netdev;
+       fcoe->real_dev = netdev;
+       fcoe->phys_dev = netdev;
 
        /* Require support for get_pauseparam ethtool op. */
        if (netdev->priv_flags & IFF_802_1Q_VLAN)
-               port->phys_dev = vlan_dev_real_dev(netdev);
+               fcoe->phys_dev = vlan_dev_real_dev(netdev);
 
        /* Do not support for bonding device */
-       if ((port->real_dev->priv_flags & IFF_MASTER_ALB) ||
-           (port->real_dev->priv_flags & IFF_SLAVE_INACTIVE) ||
-           (port->real_dev->priv_flags & IFF_MASTER_8023AD)) {
+       if ((fcoe->real_dev->priv_flags & IFF_MASTER_ALB) ||
+           (fcoe->real_dev->priv_flags & IFF_SLAVE_INACTIVE) ||
+           (fcoe->real_dev->priv_flags & IFF_MASTER_8023AD)) {
                return -EOPNOTSUPP;
        }
 
@@ -292,7 +298,7 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct 
net_device *netdev)
         * user-configured limit.  If the MFS is too low, fcoe_link_ok()
         * will return 0, so do this first.
         */
-       mfs = port->real_dev->mtu - (sizeof(struct fcoe_hdr) +
+       mfs = fcoe->real_dev->mtu - (sizeof(struct fcoe_hdr) +
                                   sizeof(struct fcoe_crc_eof));
        if (fc_set_mfs(lp, mfs))
                return -EINVAL;
@@ -336,13 +342,13 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct 
net_device *netdev)
 
        /* setup Source Mac Address */
        if (!port->ctlr.spma)
-               memcpy(port->ctlr.ctl_src_addr, port->real_dev->dev_addr,
-                      port->real_dev->addr_len);
+               memcpy(port->ctlr.ctl_src_addr, fcoe->real_dev->dev_addr,
+                      fcoe->real_dev->addr_len);
 
-       wwnn = fcoe_wwn_from_mac(port->real_dev->dev_addr, 1, 0);
+       wwnn = fcoe_wwn_from_mac(fcoe->real_dev->dev_addr, 1, 0);
        fc_set_wwnn(lp, wwnn);
        /* XXX - 3rd arg needs to be vlan id */
-       wwpn = fcoe_wwn_from_mac(port->real_dev->dev_addr, 2, 0);
+       wwpn = fcoe_wwn_from_mac(fcoe->real_dev->dev_addr, 2, 0);
        fc_set_wwpn(lp, wwpn);
 
        /*
@@ -352,10 +358,10 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct 
net_device *netdev)
         */
        rtnl_lock();
        memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
-       dev_unicast_add(port->real_dev, flogi_maddr);
+       dev_unicast_add(fcoe->real_dev, flogi_maddr);
        if (port->ctlr.spma)
-               dev_unicast_add(port->real_dev, port->ctlr.ctl_src_addr);
-       dev_mc_add(port->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
+               dev_unicast_add(fcoe->real_dev, port->ctlr.ctl_src_addr);
+       dev_mc_add(fcoe->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
        rtnl_unlock();
 
        /*
@@ -364,12 +370,12 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct 
net_device *netdev)
         */
        port->fcoe_packet_type.func = fcoe_rcv;
        port->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE);
-       port->fcoe_packet_type.dev = port->real_dev;
+       port->fcoe_packet_type.dev = fcoe->real_dev;
        dev_add_pack(&port->fcoe_packet_type);
 
        port->fip_packet_type.func = fcoe_fip_recv;
        port->fip_packet_type.type = htons(ETH_P_FIP);
-       port->fip_packet_type.dev = port->real_dev;
+       port->fip_packet_type.dev = fcoe->real_dev;
        dev_add_pack(&port->fip_packet_type);
 
        return 0;
@@ -433,9 +439,10 @@ bool fcoe_oem_match(struct fc_frame *fp)
  */
 static inline int fcoe_em_config(struct fc_lport *lp)
 {
-       struct fcoe_interface *fcoe;
        struct fcoe_port *port = lport_priv(lp);
-       struct fcoe_port *oldfc = NULL;
+       struct fcoe_port *oldport = NULL;
+       struct fcoe_interface *fcoe = port->fcoe;
+       struct fcoe_interface *oldfcoe = NULL;
        u16 min_xid = FCOE_MIN_XID;
        u16 max_xid = FCOE_MAX_XID;
 
@@ -452,10 +459,10 @@ static inline int fcoe_em_config(struct fc_lport *lp)
         * Reuse existing offload em instance in case
         * it is already allocated on phys_dev.
         */
-       list_for_each_entry(fcoe, &fcoe_hostlist, list) {
-               oldfc = fcoe->priv;
-               if (oldfc->phys_dev == port->phys_dev) {
-                       port->oem = oldfc->oem;
+       list_for_each_entry(oldfcoe, &fcoe_hostlist, list) {
+               if (oldfcoe->phys_dev == fcoe->phys_dev) {
+                       oldport = oldfcoe->priv;
+                       port->oem = oldport->oem;
                        break;
                }
        }
@@ -464,7 +471,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
                if (!fc_exch_mgr_add(lp, port->oem, fcoe_oem_match)) {
                        printk(KERN_ERR "fcoe_em_config: failed to add "
                               "offload em:%p on interface:%s\n",
-                              port->oem, port->real_dev->name);
+                              port->oem, fcoe->real_dev->name);
                        return -ENOMEM;
                }
        } else {
@@ -474,7 +481,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
                if (!port->oem) {
                        printk(KERN_ERR "fcoe_em_config: failed to allocate "
                               "em for offload exches on interface:%s\n",
-                              port->real_dev->name);
+                              fcoe->real_dev->name);
                        return -ENOMEM;
                }
        }
@@ -487,7 +494,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
 skip_oem:
        if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, min_xid, max_xid, NULL)) {
                printk(KERN_ERR "fcoe_em_config: failed to "
-                      "allocate em on interface %s\n", port->real_dev->name);
+                      "allocate em on interface %s\n", fcoe->real_dev->name);
                return -ENOMEM;
        }
 
@@ -502,7 +509,7 @@ static void fcoe_if_destroy(struct fc_lport *lport)
 {
        struct fcoe_port *port = lport_priv(lport);
        struct fcoe_interface *fcoe = port->fcoe;
-       struct net_device *netdev = port->real_dev;
+       struct net_device *netdev = fcoe->real_dev;
 
        FCOE_NETDEV_DBG(netdev, "Destroying interface\n");
 
@@ -542,7 +549,7 @@ static void fcoe_if_destroy(struct fc_lport *lport)
        fc_lport_free_stats(lport);
 
        /* Release the net_device and Scsi_Host */
-       dev_put(port->real_dev);
+       dev_put(fcoe->real_dev);
        scsi_host_put(lport->host);
        kfree(fcoe);            /* TODO, should be refcounted */
 }
@@ -1183,7 +1190,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
        skb_reset_network_header(skb);
        skb->mac_len = elen;
        skb->protocol = htons(ETH_P_FCOE);
-       skb->dev = port->real_dev;
+       skb->dev = port->fcoe->real_dev;
 
        /* fill up mac and fcoe headers */
        eh = eth_hdr(skb);
@@ -1469,7 +1476,7 @@ static int fcoe_device_notification(struct notifier_block 
*notifier,
        read_lock(&fcoe_hostlist_lock);
        list_for_each_entry(fcoe, &fcoe_hostlist, list) {
                port = fcoe->priv;
-               if (port->real_dev == real_dev) {
+               if (fcoe->real_dev == real_dev) {
                        lp = port->ctlr.lp;
                        break;
                }
@@ -1489,7 +1496,7 @@ static int fcoe_device_notification(struct notifier_block 
*notifier,
        case NETDEV_CHANGE:
                break;
        case NETDEV_CHANGEMTU:
-               mfs = port->real_dev->mtu -
+               mfs = fcoe->real_dev->mtu -
                        (sizeof(struct fcoe_hdr) +
                         sizeof(struct fcoe_crc_eof));
                if (mfs >= FC_MIN_MAX_FRAME)
@@ -1699,7 +1706,7 @@ MODULE_PARM_DESC(destroy, "Destroy fcoe fcoe");
 int fcoe_link_ok(struct fc_lport *lp)
 {
        struct fcoe_port *port = lport_priv(lp);
-       struct net_device *dev = port->real_dev;
+       struct net_device *dev = port->fcoe->real_dev;
        struct ethtool_cmd ecmd = { ETHTOOL_GSET };
 
        if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) &&
@@ -1800,7 +1807,7 @@ fcoe_hostlist_lookup_port(const struct net_device *dev)
        struct fcoe_interface *fcoe;
 
        list_for_each_entry(fcoe, &fcoe_hostlist, list) {
-               if (fcoe->priv->real_dev == dev)
+               if (fcoe->real_dev == dev)
                        return fcoe;
        }
        return NULL;
diff --git a/drivers/scsi/fcoe/fcoe.h b/drivers/scsi/fcoe/fcoe.h
index 3c85f48..fd7429d 100644
--- a/drivers/scsi/fcoe/fcoe.h
+++ b/drivers/scsi/fcoe/fcoe.h
@@ -82,6 +82,8 @@ struct fcoe_interface {
        /* This will be removed once all the shared values are
         * moved out of fcoe_port */
        struct fcoe_port *priv;
+       struct net_device *real_dev;
+       struct net_device *phys_dev;            /* device with ethtool_ops */
 };
 
 /*
@@ -90,8 +92,6 @@ struct fcoe_interface {
  */
 struct fcoe_port {
        struct fcoe_interface *fcoe;
-       struct net_device *real_dev;
-       struct net_device *phys_dev;            /* device with ethtool_ops */
        struct fc_exch_mgr *oem;                /* offload exchange manger */
        struct packet_type  fcoe_packet_type;
        struct packet_type  fip_packet_type;
@@ -101,12 +101,11 @@ struct fcoe_port {
        struct fcoe_ctlr ctlr;
 };
 
-#define fcoe_from_ctlr(port) container_of(port, struct fcoe_port, ctlr)
+#define fcoe_from_ctlr(fip) container_of(fip, struct fcoe_port, ctlr)
 
-static inline struct net_device *fcoe_netdev(
-       const struct fc_lport *lp)
+static inline struct net_device *fcoe_netdev(const struct fc_lport *lp)
 {
-       return ((struct fcoe_port *)lport_priv(lp))->real_dev;
+       return ((struct fcoe_port *)lport_priv(lp))->fcoe->real_dev;
 }
 
 #endif /* _FCOE_H_ */

_______________________________________________
devel mailing list
[email protected]
http://www.open-fcoe.org/mailman/listinfo/devel

Reply via email to