Commit 1d1b88dc authored by Vasu Dev's avatar Vasu Dev Committed by James Bottomley

[SCSI] fcoe: removes phys_dev and renames real_dev to netdev.

The phys_dev was used only to locate common offload EM instance for all
FCoE instances on a eth devices in function fcoe_em_config, so just updated
fcoe_em_config to look for actual real eth device in locating common offload
EM instance and then no need to store phys_dev in fcoe_softc, so removes
phys_dev from fcoe_softc also.

Renames fcoe_softc real_dev to netdev and updates all its uses to use netdev.

So effectively no functional change, use of single netdev instead phys_dev
and real_dev saves one pointer memory in fcoe_softc, also real_dev used here
was confusing with vlan driver terminology since real_dev in vlan driver is
referred to physical eth device.
Signed-off-by: default avatarVasu Dev <vasu.dev@intel.com>
Signed-off-by: default avatarRobert Love <robert.w.love@intel.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 53fcfbbe
...@@ -159,7 +159,7 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev, ...@@ -159,7 +159,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) 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)->netdev;
dev_queue_xmit(skb); dev_queue_xmit(skb);
} }
...@@ -179,8 +179,8 @@ static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new) ...@@ -179,8 +179,8 @@ static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new)
fc = fcoe_from_ctlr(fip); fc = fcoe_from_ctlr(fip);
rtnl_lock(); rtnl_lock();
if (!is_zero_ether_addr(old)) if (!is_zero_ether_addr(old))
dev_unicast_delete(fc->real_dev, old); dev_unicast_delete(fc->netdev, old);
dev_unicast_add(fc->real_dev, new); dev_unicast_add(fc->netdev, new);
rtnl_unlock(); rtnl_unlock();
} }
...@@ -231,12 +231,12 @@ void fcoe_netdev_cleanup(struct fcoe_softc *fc) ...@@ -231,12 +231,12 @@ void fcoe_netdev_cleanup(struct fcoe_softc *fc)
/* Delete secondary MAC addresses */ /* Delete secondary MAC addresses */
rtnl_lock(); rtnl_lock();
memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
dev_unicast_delete(fc->real_dev, flogi_maddr); dev_unicast_delete(fc->netdev, flogi_maddr);
if (!is_zero_ether_addr(fc->ctlr.data_src_addr)) if (!is_zero_ether_addr(fc->ctlr.data_src_addr))
dev_unicast_delete(fc->real_dev, fc->ctlr.data_src_addr); dev_unicast_delete(fc->netdev, fc->ctlr.data_src_addr);
if (fc->ctlr.spma) if (fc->ctlr.spma)
dev_unicast_delete(fc->real_dev, fc->ctlr.ctl_src_addr); dev_unicast_delete(fc->netdev, fc->ctlr.ctl_src_addr);
dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); dev_mc_delete(fc->netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
rtnl_unlock(); rtnl_unlock();
} }
...@@ -272,17 +272,12 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) ...@@ -272,17 +272,12 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
/* Setup lport private data to point to fcoe softc */ /* Setup lport private data to point to fcoe softc */
fc = lport_priv(lp); fc = lport_priv(lp);
fc->ctlr.lp = lp; fc->ctlr.lp = lp;
fc->real_dev = netdev; fc->netdev = netdev;
fc->phys_dev = netdev;
/* Require support for get_pauseparam ethtool op. */
if (netdev->priv_flags & IFF_802_1Q_VLAN)
fc->phys_dev = vlan_dev_real_dev(netdev);
/* Do not support for bonding device */ /* Do not support for bonding device */
if ((fc->real_dev->priv_flags & IFF_MASTER_ALB) || if ((netdev->priv_flags & IFF_MASTER_ALB) ||
(fc->real_dev->priv_flags & IFF_SLAVE_INACTIVE) || (netdev->priv_flags & IFF_SLAVE_INACTIVE) ||
(fc->real_dev->priv_flags & IFF_MASTER_8023AD)) { (netdev->priv_flags & IFF_MASTER_8023AD)) {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -291,13 +286,13 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) ...@@ -291,13 +286,13 @@ 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() * user-configured limit. If the MFS is too low, fcoe_link_ok()
* will return 0, so do this first. * will return 0, so do this first.
*/ */
mfs = fc->real_dev->mtu - (sizeof(struct fcoe_hdr) + mfs = netdev->mtu - (sizeof(struct fcoe_hdr) +
sizeof(struct fcoe_crc_eof)); sizeof(struct fcoe_crc_eof));
if (fc_set_mfs(lp, mfs)) if (fc_set_mfs(lp, mfs))
return -EINVAL; return -EINVAL;
/* offload features support */ /* offload features support */
if (fc->real_dev->features & NETIF_F_SG) if (netdev->features & NETIF_F_SG)
lp->sg_supp = 1; lp->sg_supp = 1;
if (netdev->features & NETIF_F_FCOE_CRC) { if (netdev->features & NETIF_F_FCOE_CRC) {
...@@ -335,13 +330,13 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) ...@@ -335,13 +330,13 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
/* setup Source Mac Address */ /* setup Source Mac Address */
if (!fc->ctlr.spma) if (!fc->ctlr.spma)
memcpy(fc->ctlr.ctl_src_addr, fc->real_dev->dev_addr, memcpy(fc->ctlr.ctl_src_addr, netdev->dev_addr,
fc->real_dev->addr_len); fc->netdev->addr_len);
wwnn = fcoe_wwn_from_mac(fc->real_dev->dev_addr, 1, 0); wwnn = fcoe_wwn_from_mac(netdev->dev_addr, 1, 0);
fc_set_wwnn(lp, wwnn); fc_set_wwnn(lp, wwnn);
/* XXX - 3rd arg needs to be vlan id */ /* XXX - 3rd arg needs to be vlan id */
wwpn = fcoe_wwn_from_mac(fc->real_dev->dev_addr, 2, 0); wwpn = fcoe_wwn_from_mac(netdev->dev_addr, 2, 0);
fc_set_wwpn(lp, wwpn); fc_set_wwpn(lp, wwpn);
/* /*
...@@ -351,10 +346,10 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) ...@@ -351,10 +346,10 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
*/ */
rtnl_lock(); rtnl_lock();
memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
dev_unicast_add(fc->real_dev, flogi_maddr); dev_unicast_add(netdev, flogi_maddr);
if (fc->ctlr.spma) if (fc->ctlr.spma)
dev_unicast_add(fc->real_dev, fc->ctlr.ctl_src_addr); dev_unicast_add(netdev, fc->ctlr.ctl_src_addr);
dev_mc_add(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); dev_mc_add(netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
rtnl_unlock(); rtnl_unlock();
/* /*
...@@ -363,12 +358,12 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) ...@@ -363,12 +358,12 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
*/ */
fc->fcoe_packet_type.func = fcoe_rcv; fc->fcoe_packet_type.func = fcoe_rcv;
fc->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE); fc->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE);
fc->fcoe_packet_type.dev = fc->real_dev; fc->fcoe_packet_type.dev = netdev;
dev_add_pack(&fc->fcoe_packet_type); dev_add_pack(&fc->fcoe_packet_type);
fc->fip_packet_type.func = fcoe_fip_recv; fc->fip_packet_type.func = fcoe_fip_recv;
fc->fip_packet_type.type = htons(ETH_P_FIP); fc->fip_packet_type.type = htons(ETH_P_FIP);
fc->fip_packet_type.dev = fc->real_dev; fc->fip_packet_type.dev = netdev;
dev_add_pack(&fc->fip_packet_type); dev_add_pack(&fc->fip_packet_type);
return 0; return 0;
...@@ -434,6 +429,7 @@ static inline int fcoe_em_config(struct fc_lport *lp) ...@@ -434,6 +429,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
{ {
struct fcoe_softc *fc = lport_priv(lp); struct fcoe_softc *fc = lport_priv(lp);
struct fcoe_softc *oldfc = NULL; struct fcoe_softc *oldfc = NULL;
struct net_device *old_real_dev, *cur_real_dev;
u16 min_xid = FCOE_MIN_XID; u16 min_xid = FCOE_MIN_XID;
u16 max_xid = FCOE_MAX_XID; u16 max_xid = FCOE_MAX_XID;
...@@ -448,10 +444,20 @@ static inline int fcoe_em_config(struct fc_lport *lp) ...@@ -448,10 +444,20 @@ static inline int fcoe_em_config(struct fc_lport *lp)
/* /*
* Reuse existing offload em instance in case * Reuse existing offload em instance in case
* it is already allocated on phys_dev. * it is already allocated on real eth device
*/ */
if (fc->netdev->priv_flags & IFF_802_1Q_VLAN)
cur_real_dev = vlan_dev_real_dev(fc->netdev);
else
cur_real_dev = fc->netdev;
list_for_each_entry(oldfc, &fcoe_hostlist, list) { list_for_each_entry(oldfc, &fcoe_hostlist, list) {
if (oldfc->phys_dev == fc->phys_dev) { if (oldfc->netdev->priv_flags & IFF_802_1Q_VLAN)
old_real_dev = vlan_dev_real_dev(oldfc->netdev);
else
old_real_dev = oldfc->netdev;
if (cur_real_dev == old_real_dev) {
fc->oem = oldfc->oem; fc->oem = oldfc->oem;
break; break;
} }
...@@ -461,7 +467,7 @@ static inline int fcoe_em_config(struct fc_lport *lp) ...@@ -461,7 +467,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
if (!fc_exch_mgr_add(lp, fc->oem, fcoe_oem_match)) { if (!fc_exch_mgr_add(lp, fc->oem, fcoe_oem_match)) {
printk(KERN_ERR "fcoe_em_config: failed to add " printk(KERN_ERR "fcoe_em_config: failed to add "
"offload em:%p on interface:%s\n", "offload em:%p on interface:%s\n",
fc->oem, fc->real_dev->name); fc->oem, fc->netdev->name);
return -ENOMEM; return -ENOMEM;
} }
} else { } else {
...@@ -471,7 +477,7 @@ static inline int fcoe_em_config(struct fc_lport *lp) ...@@ -471,7 +477,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
if (!fc->oem) { if (!fc->oem) {
printk(KERN_ERR "fcoe_em_config: failed to allocate " printk(KERN_ERR "fcoe_em_config: failed to allocate "
"em for offload exches on interface:%s\n", "em for offload exches on interface:%s\n",
fc->real_dev->name); fc->netdev->name);
return -ENOMEM; return -ENOMEM;
} }
} }
...@@ -484,7 +490,7 @@ static inline int fcoe_em_config(struct fc_lport *lp) ...@@ -484,7 +490,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
skip_oem: skip_oem:
if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, min_xid, max_xid, NULL)) { if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, min_xid, max_xid, NULL)) {
printk(KERN_ERR "fcoe_em_config: failed to " printk(KERN_ERR "fcoe_em_config: failed to "
"allocate em on interface %s\n", fc->real_dev->name); "allocate em on interface %s\n", fc->netdev->name);
return -ENOMEM; return -ENOMEM;
} }
...@@ -548,7 +554,7 @@ static int fcoe_if_destroy(struct net_device *netdev) ...@@ -548,7 +554,7 @@ static int fcoe_if_destroy(struct net_device *netdev)
fc_lport_free_stats(lp); fc_lport_free_stats(lp);
/* Release the net_device and Scsi_Host */ /* Release the net_device and Scsi_Host */
dev_put(fc->real_dev); dev_put(netdev);
scsi_host_put(lp->host); scsi_host_put(lp->host);
return 0; return 0;
...@@ -1179,7 +1185,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) ...@@ -1179,7 +1185,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
skb_reset_network_header(skb); skb_reset_network_header(skb);
skb->mac_len = elen; skb->mac_len = elen;
skb->protocol = htons(ETH_P_FCOE); skb->protocol = htons(ETH_P_FCOE);
skb->dev = fc->real_dev; skb->dev = fc->netdev;
/* fill up mac and fcoe headers */ /* fill up mac and fcoe headers */
eh = eth_hdr(skb); eh = eth_hdr(skb);
...@@ -1454,7 +1460,7 @@ static int fcoe_device_notification(struct notifier_block *notifier, ...@@ -1454,7 +1460,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
ulong event, void *ptr) ulong event, void *ptr)
{ {
struct fc_lport *lp = NULL; struct fc_lport *lp = NULL;
struct net_device *real_dev = ptr; struct net_device *netdev = ptr;
struct fcoe_softc *fc; struct fcoe_softc *fc;
struct fcoe_dev_stats *stats; struct fcoe_dev_stats *stats;
u32 link_possible = 1; u32 link_possible = 1;
...@@ -1463,7 +1469,7 @@ static int fcoe_device_notification(struct notifier_block *notifier, ...@@ -1463,7 +1469,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
read_lock(&fcoe_hostlist_lock); read_lock(&fcoe_hostlist_lock);
list_for_each_entry(fc, &fcoe_hostlist, list) { list_for_each_entry(fc, &fcoe_hostlist, list) {
if (fc->real_dev == real_dev) { if (fc->netdev == netdev) {
lp = fc->ctlr.lp; lp = fc->ctlr.lp;
break; break;
} }
...@@ -1483,8 +1489,7 @@ static int fcoe_device_notification(struct notifier_block *notifier, ...@@ -1483,8 +1489,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
case NETDEV_CHANGE: case NETDEV_CHANGE:
break; break;
case NETDEV_CHANGEMTU: case NETDEV_CHANGEMTU:
mfs = fc->real_dev->mtu - mfs = netdev->mtu - (sizeof(struct fcoe_hdr) +
(sizeof(struct fcoe_hdr) +
sizeof(struct fcoe_crc_eof)); sizeof(struct fcoe_crc_eof));
if (mfs >= FC_MIN_MAX_FRAME) if (mfs >= FC_MIN_MAX_FRAME)
fc_set_mfs(lp, mfs); fc_set_mfs(lp, mfs);
...@@ -1492,7 +1497,7 @@ static int fcoe_device_notification(struct notifier_block *notifier, ...@@ -1492,7 +1497,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
case NETDEV_REGISTER: case NETDEV_REGISTER:
break; break;
default: default:
FCOE_NETDEV_DBG(real_dev, "Unknown event %ld " FCOE_NETDEV_DBG(netdev, "Unknown event %ld "
"from netdev netlink\n", event); "from netdev netlink\n", event);
} }
if (link_possible && !fcoe_link_ok(lp)) if (link_possible && !fcoe_link_ok(lp))
...@@ -1696,7 +1701,7 @@ MODULE_PARM_DESC(destroy, "Destroy fcoe port"); ...@@ -1696,7 +1701,7 @@ MODULE_PARM_DESC(destroy, "Destroy fcoe port");
int fcoe_link_ok(struct fc_lport *lp) int fcoe_link_ok(struct fc_lport *lp)
{ {
struct fcoe_softc *fc = lport_priv(lp); struct fcoe_softc *fc = lport_priv(lp);
struct net_device *dev = fc->real_dev; struct net_device *dev = fc->netdev;
struct ethtool_cmd ecmd = { ETHTOOL_GSET }; struct ethtool_cmd ecmd = { ETHTOOL_GSET };
if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) && if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) &&
...@@ -1797,7 +1802,7 @@ fcoe_hostlist_lookup_softc(const struct net_device *dev) ...@@ -1797,7 +1802,7 @@ fcoe_hostlist_lookup_softc(const struct net_device *dev)
struct fcoe_softc *fc; struct fcoe_softc *fc;
list_for_each_entry(fc, &fcoe_hostlist, list) { list_for_each_entry(fc, &fcoe_hostlist, list) {
if (fc->real_dev == dev) if (fc->netdev == dev)
return fc; return fc;
} }
return NULL; return NULL;
...@@ -1916,7 +1921,7 @@ static void __exit fcoe_exit(void) ...@@ -1916,7 +1921,7 @@ static void __exit fcoe_exit(void)
/* releases the associated fcoe hosts */ /* releases the associated fcoe hosts */
list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list) list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list)
fcoe_if_destroy(fc->real_dev); fcoe_if_destroy(fc->netdev);
unregister_hotcpu_notifier(&fcoe_cpu_notifier); unregister_hotcpu_notifier(&fcoe_cpu_notifier);
......
...@@ -79,8 +79,7 @@ struct fcoe_percpu_s { ...@@ -79,8 +79,7 @@ struct fcoe_percpu_s {
*/ */
struct fcoe_softc { struct fcoe_softc {
struct list_head list; struct list_head list;
struct net_device *real_dev; struct net_device *netdev;
struct net_device *phys_dev; /* device with ethtool_ops */
struct fc_exch_mgr *oem; /* offload exchange manger */ struct fc_exch_mgr *oem; /* offload exchange manger */
struct packet_type fcoe_packet_type; struct packet_type fcoe_packet_type;
struct packet_type fip_packet_type; struct packet_type fip_packet_type;
...@@ -95,7 +94,7 @@ struct fcoe_softc { ...@@ -95,7 +94,7 @@ struct fcoe_softc {
static inline struct net_device *fcoe_netdev( static inline struct net_device *fcoe_netdev(
const struct fc_lport *lp) const struct fc_lport *lp)
{ {
return ((struct fcoe_softc *)lport_priv(lp))->real_dev; return ((struct fcoe_softc *)lport_priv(lp))->netdev;
} }
#endif /* _FCOE_H_ */ #endif /* _FCOE_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment