aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasu Dev <vasu.dev@intel.com>2009-07-29 20:05:45 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-08-22 18:52:11 -0400
commit1d1b88dc01e5fd2b3e2abb7aa42d0f1eca4c33ea (patch)
treecf08966d7c2f7e81c989b312e173d37ba4a59ef9
parent53fcfbbef569819706b880a502ff62e2852edfce (diff)
[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: Vasu Dev <vasu.dev@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r--drivers/scsi/fcoe/fcoe.c93
-rw-r--r--drivers/scsi/fcoe/fcoe.h5
2 files changed, 51 insertions, 47 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index ad21e87e4006..757aa28f0f04 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -159,7 +159,7 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev,
159 */ 159 */
160static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb) 160static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
161{ 161{
162 skb->dev = fcoe_from_ctlr(fip)->real_dev; 162 skb->dev = fcoe_from_ctlr(fip)->netdev;
163 dev_queue_xmit(skb); 163 dev_queue_xmit(skb);
164} 164}
165 165
@@ -179,8 +179,8 @@ static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new)
179 fc = fcoe_from_ctlr(fip); 179 fc = fcoe_from_ctlr(fip);
180 rtnl_lock(); 180 rtnl_lock();
181 if (!is_zero_ether_addr(old)) 181 if (!is_zero_ether_addr(old))
182 dev_unicast_delete(fc->real_dev, old); 182 dev_unicast_delete(fc->netdev, old);
183 dev_unicast_add(fc->real_dev, new); 183 dev_unicast_add(fc->netdev, new);
184 rtnl_unlock(); 184 rtnl_unlock();
185} 185}
186 186
@@ -231,12 +231,12 @@ void fcoe_netdev_cleanup(struct fcoe_softc *fc)
231 /* Delete secondary MAC addresses */ 231 /* Delete secondary MAC addresses */
232 rtnl_lock(); 232 rtnl_lock();
233 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); 233 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
234 dev_unicast_delete(fc->real_dev, flogi_maddr); 234 dev_unicast_delete(fc->netdev, flogi_maddr);
235 if (!is_zero_ether_addr(fc->ctlr.data_src_addr)) 235 if (!is_zero_ether_addr(fc->ctlr.data_src_addr))
236 dev_unicast_delete(fc->real_dev, fc->ctlr.data_src_addr); 236 dev_unicast_delete(fc->netdev, fc->ctlr.data_src_addr);
237 if (fc->ctlr.spma) 237 if (fc->ctlr.spma)
238 dev_unicast_delete(fc->real_dev, fc->ctlr.ctl_src_addr); 238 dev_unicast_delete(fc->netdev, fc->ctlr.ctl_src_addr);
239 dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); 239 dev_mc_delete(fc->netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
240 rtnl_unlock(); 240 rtnl_unlock();
241} 241}
242 242
@@ -272,17 +272,12 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
272 /* Setup lport private data to point to fcoe softc */ 272 /* Setup lport private data to point to fcoe softc */
273 fc = lport_priv(lp); 273 fc = lport_priv(lp);
274 fc->ctlr.lp = lp; 274 fc->ctlr.lp = lp;
275 fc->real_dev = netdev; 275 fc->netdev = netdev;
276 fc->phys_dev = netdev;
277
278 /* Require support for get_pauseparam ethtool op. */
279 if (netdev->priv_flags & IFF_802_1Q_VLAN)
280 fc->phys_dev = vlan_dev_real_dev(netdev);
281 276
282 /* Do not support for bonding device */ 277 /* Do not support for bonding device */
283 if ((fc->real_dev->priv_flags & IFF_MASTER_ALB) || 278 if ((netdev->priv_flags & IFF_MASTER_ALB) ||
284 (fc->real_dev->priv_flags & IFF_SLAVE_INACTIVE) || 279 (netdev->priv_flags & IFF_SLAVE_INACTIVE) ||
285 (fc->real_dev->priv_flags & IFF_MASTER_8023AD)) { 280 (netdev->priv_flags & IFF_MASTER_8023AD)) {
286 return -EOPNOTSUPP; 281 return -EOPNOTSUPP;
287 } 282 }
288 283
@@ -291,13 +286,13 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
291 * user-configured limit. If the MFS is too low, fcoe_link_ok() 286 * user-configured limit. If the MFS is too low, fcoe_link_ok()
292 * will return 0, so do this first. 287 * will return 0, so do this first.
293 */ 288 */
294 mfs = fc->real_dev->mtu - (sizeof(struct fcoe_hdr) + 289 mfs = netdev->mtu - (sizeof(struct fcoe_hdr) +
295 sizeof(struct fcoe_crc_eof)); 290 sizeof(struct fcoe_crc_eof));
296 if (fc_set_mfs(lp, mfs)) 291 if (fc_set_mfs(lp, mfs))
297 return -EINVAL; 292 return -EINVAL;
298 293
299 /* offload features support */ 294 /* offload features support */
300 if (fc->real_dev->features & NETIF_F_SG) 295 if (netdev->features & NETIF_F_SG)
301 lp->sg_supp = 1; 296 lp->sg_supp = 1;
302 297
303 if (netdev->features & NETIF_F_FCOE_CRC) { 298 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 330
336 /* setup Source Mac Address */ 331 /* setup Source Mac Address */
337 if (!fc->ctlr.spma) 332 if (!fc->ctlr.spma)
338 memcpy(fc->ctlr.ctl_src_addr, fc->real_dev->dev_addr, 333 memcpy(fc->ctlr.ctl_src_addr, netdev->dev_addr,
339 fc->real_dev->addr_len); 334 fc->netdev->addr_len);
340 335
341 wwnn = fcoe_wwn_from_mac(fc->real_dev->dev_addr, 1, 0); 336 wwnn = fcoe_wwn_from_mac(netdev->dev_addr, 1, 0);
342 fc_set_wwnn(lp, wwnn); 337 fc_set_wwnn(lp, wwnn);
343 /* XXX - 3rd arg needs to be vlan id */ 338 /* XXX - 3rd arg needs to be vlan id */
344 wwpn = fcoe_wwn_from_mac(fc->real_dev->dev_addr, 2, 0); 339 wwpn = fcoe_wwn_from_mac(netdev->dev_addr, 2, 0);
345 fc_set_wwpn(lp, wwpn); 340 fc_set_wwpn(lp, wwpn);
346 341
347 /* 342 /*
@@ -351,10 +346,10 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
351 */ 346 */
352 rtnl_lock(); 347 rtnl_lock();
353 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); 348 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
354 dev_unicast_add(fc->real_dev, flogi_maddr); 349 dev_unicast_add(netdev, flogi_maddr);
355 if (fc->ctlr.spma) 350 if (fc->ctlr.spma)
356 dev_unicast_add(fc->real_dev, fc->ctlr.ctl_src_addr); 351 dev_unicast_add(netdev, fc->ctlr.ctl_src_addr);
357 dev_mc_add(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); 352 dev_mc_add(netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
358 rtnl_unlock(); 353 rtnl_unlock();
359 354
360 /* 355 /*
@@ -363,12 +358,12 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
363 */ 358 */
364 fc->fcoe_packet_type.func = fcoe_rcv; 359 fc->fcoe_packet_type.func = fcoe_rcv;
365 fc->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE); 360 fc->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE);
366 fc->fcoe_packet_type.dev = fc->real_dev; 361 fc->fcoe_packet_type.dev = netdev;
367 dev_add_pack(&fc->fcoe_packet_type); 362 dev_add_pack(&fc->fcoe_packet_type);
368 363
369 fc->fip_packet_type.func = fcoe_fip_recv; 364 fc->fip_packet_type.func = fcoe_fip_recv;
370 fc->fip_packet_type.type = htons(ETH_P_FIP); 365 fc->fip_packet_type.type = htons(ETH_P_FIP);
371 fc->fip_packet_type.dev = fc->real_dev; 366 fc->fip_packet_type.dev = netdev;
372 dev_add_pack(&fc->fip_packet_type); 367 dev_add_pack(&fc->fip_packet_type);
373 368
374 return 0; 369 return 0;
@@ -434,6 +429,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
434{ 429{
435 struct fcoe_softc *fc = lport_priv(lp); 430 struct fcoe_softc *fc = lport_priv(lp);
436 struct fcoe_softc *oldfc = NULL; 431 struct fcoe_softc *oldfc = NULL;
432 struct net_device *old_real_dev, *cur_real_dev;
437 u16 min_xid = FCOE_MIN_XID; 433 u16 min_xid = FCOE_MIN_XID;
438 u16 max_xid = FCOE_MAX_XID; 434 u16 max_xid = FCOE_MAX_XID;
439 435
@@ -448,10 +444,20 @@ static inline int fcoe_em_config(struct fc_lport *lp)
448 444
449 /* 445 /*
450 * Reuse existing offload em instance in case 446 * Reuse existing offload em instance in case
451 * it is already allocated on phys_dev. 447 * it is already allocated on real eth device
452 */ 448 */
449 if (fc->netdev->priv_flags & IFF_802_1Q_VLAN)
450 cur_real_dev = vlan_dev_real_dev(fc->netdev);
451 else
452 cur_real_dev = fc->netdev;
453
453 list_for_each_entry(oldfc, &fcoe_hostlist, list) { 454 list_for_each_entry(oldfc, &fcoe_hostlist, list) {
454 if (oldfc->phys_dev == fc->phys_dev) { 455 if (oldfc->netdev->priv_flags & IFF_802_1Q_VLAN)
456 old_real_dev = vlan_dev_real_dev(oldfc->netdev);
457 else
458 old_real_dev = oldfc->netdev;
459
460 if (cur_real_dev == old_real_dev) {
455 fc->oem = oldfc->oem; 461 fc->oem = oldfc->oem;
456 break; 462 break;
457 } 463 }
@@ -461,7 +467,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
461 if (!fc_exch_mgr_add(lp, fc->oem, fcoe_oem_match)) { 467 if (!fc_exch_mgr_add(lp, fc->oem, fcoe_oem_match)) {
462 printk(KERN_ERR "fcoe_em_config: failed to add " 468 printk(KERN_ERR "fcoe_em_config: failed to add "
463 "offload em:%p on interface:%s\n", 469 "offload em:%p on interface:%s\n",
464 fc->oem, fc->real_dev->name); 470 fc->oem, fc->netdev->name);
465 return -ENOMEM; 471 return -ENOMEM;
466 } 472 }
467 } else { 473 } else {
@@ -471,7 +477,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
471 if (!fc->oem) { 477 if (!fc->oem) {
472 printk(KERN_ERR "fcoe_em_config: failed to allocate " 478 printk(KERN_ERR "fcoe_em_config: failed to allocate "
473 "em for offload exches on interface:%s\n", 479 "em for offload exches on interface:%s\n",
474 fc->real_dev->name); 480 fc->netdev->name);
475 return -ENOMEM; 481 return -ENOMEM;
476 } 482 }
477 } 483 }
@@ -484,7 +490,7 @@ static inline int fcoe_em_config(struct fc_lport *lp)
484skip_oem: 490skip_oem:
485 if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, min_xid, max_xid, NULL)) { 491 if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, min_xid, max_xid, NULL)) {
486 printk(KERN_ERR "fcoe_em_config: failed to " 492 printk(KERN_ERR "fcoe_em_config: failed to "
487 "allocate em on interface %s\n", fc->real_dev->name); 493 "allocate em on interface %s\n", fc->netdev->name);
488 return -ENOMEM; 494 return -ENOMEM;
489 } 495 }
490 496
@@ -548,7 +554,7 @@ static int fcoe_if_destroy(struct net_device *netdev)
548 fc_lport_free_stats(lp); 554 fc_lport_free_stats(lp);
549 555
550 /* Release the net_device and Scsi_Host */ 556 /* Release the net_device and Scsi_Host */
551 dev_put(fc->real_dev); 557 dev_put(netdev);
552 scsi_host_put(lp->host); 558 scsi_host_put(lp->host);
553 559
554 return 0; 560 return 0;
@@ -1179,7 +1185,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
1179 skb_reset_network_header(skb); 1185 skb_reset_network_header(skb);
1180 skb->mac_len = elen; 1186 skb->mac_len = elen;
1181 skb->protocol = htons(ETH_P_FCOE); 1187 skb->protocol = htons(ETH_P_FCOE);
1182 skb->dev = fc->real_dev; 1188 skb->dev = fc->netdev;
1183 1189
1184 /* fill up mac and fcoe headers */ 1190 /* fill up mac and fcoe headers */
1185 eh = eth_hdr(skb); 1191 eh = eth_hdr(skb);
@@ -1454,7 +1460,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
1454 ulong event, void *ptr) 1460 ulong event, void *ptr)
1455{ 1461{
1456 struct fc_lport *lp = NULL; 1462 struct fc_lport *lp = NULL;
1457 struct net_device *real_dev = ptr; 1463 struct net_device *netdev = ptr;
1458 struct fcoe_softc *fc; 1464 struct fcoe_softc *fc;
1459 struct fcoe_dev_stats *stats; 1465 struct fcoe_dev_stats *stats;
1460 u32 link_possible = 1; 1466 u32 link_possible = 1;
@@ -1463,7 +1469,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
1463 1469
1464 read_lock(&fcoe_hostlist_lock); 1470 read_lock(&fcoe_hostlist_lock);
1465 list_for_each_entry(fc, &fcoe_hostlist, list) { 1471 list_for_each_entry(fc, &fcoe_hostlist, list) {
1466 if (fc->real_dev == real_dev) { 1472 if (fc->netdev == netdev) {
1467 lp = fc->ctlr.lp; 1473 lp = fc->ctlr.lp;
1468 break; 1474 break;
1469 } 1475 }
@@ -1483,16 +1489,15 @@ static int fcoe_device_notification(struct notifier_block *notifier,
1483 case NETDEV_CHANGE: 1489 case NETDEV_CHANGE:
1484 break; 1490 break;
1485 case NETDEV_CHANGEMTU: 1491 case NETDEV_CHANGEMTU:
1486 mfs = fc->real_dev->mtu - 1492 mfs = netdev->mtu - (sizeof(struct fcoe_hdr) +
1487 (sizeof(struct fcoe_hdr) + 1493 sizeof(struct fcoe_crc_eof));
1488 sizeof(struct fcoe_crc_eof));
1489 if (mfs >= FC_MIN_MAX_FRAME) 1494 if (mfs >= FC_MIN_MAX_FRAME)
1490 fc_set_mfs(lp, mfs); 1495 fc_set_mfs(lp, mfs);
1491 break; 1496 break;
1492 case NETDEV_REGISTER: 1497 case NETDEV_REGISTER:
1493 break; 1498 break;
1494 default: 1499 default:
1495 FCOE_NETDEV_DBG(real_dev, "Unknown event %ld " 1500 FCOE_NETDEV_DBG(netdev, "Unknown event %ld "
1496 "from netdev netlink\n", event); 1501 "from netdev netlink\n", event);
1497 } 1502 }
1498 if (link_possible && !fcoe_link_ok(lp)) 1503 if (link_possible && !fcoe_link_ok(lp))
@@ -1696,7 +1701,7 @@ MODULE_PARM_DESC(destroy, "Destroy fcoe port");
1696int fcoe_link_ok(struct fc_lport *lp) 1701int fcoe_link_ok(struct fc_lport *lp)
1697{ 1702{
1698 struct fcoe_softc *fc = lport_priv(lp); 1703 struct fcoe_softc *fc = lport_priv(lp);
1699 struct net_device *dev = fc->real_dev; 1704 struct net_device *dev = fc->netdev;
1700 struct ethtool_cmd ecmd = { ETHTOOL_GSET }; 1705 struct ethtool_cmd ecmd = { ETHTOOL_GSET };
1701 1706
1702 if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) && 1707 if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) &&
@@ -1797,7 +1802,7 @@ fcoe_hostlist_lookup_softc(const struct net_device *dev)
1797 struct fcoe_softc *fc; 1802 struct fcoe_softc *fc;
1798 1803
1799 list_for_each_entry(fc, &fcoe_hostlist, list) { 1804 list_for_each_entry(fc, &fcoe_hostlist, list) {
1800 if (fc->real_dev == dev) 1805 if (fc->netdev == dev)
1801 return fc; 1806 return fc;
1802 } 1807 }
1803 return NULL; 1808 return NULL;
@@ -1916,7 +1921,7 @@ static void __exit fcoe_exit(void)
1916 1921
1917 /* releases the associated fcoe hosts */ 1922 /* releases the associated fcoe hosts */
1918 list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list) 1923 list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list)
1919 fcoe_if_destroy(fc->real_dev); 1924 fcoe_if_destroy(fc->netdev);
1920 1925
1921 unregister_hotcpu_notifier(&fcoe_cpu_notifier); 1926 unregister_hotcpu_notifier(&fcoe_cpu_notifier);
1922 1927
diff --git a/drivers/scsi/fcoe/fcoe.h b/drivers/scsi/fcoe/fcoe.h
index 6905efc166bf..5ae8ca71afcb 100644
--- a/drivers/scsi/fcoe/fcoe.h
+++ b/drivers/scsi/fcoe/fcoe.h
@@ -79,8 +79,7 @@ struct fcoe_percpu_s {
79 */ 79 */
80struct fcoe_softc { 80struct fcoe_softc {
81 struct list_head list; 81 struct list_head list;
82 struct net_device *real_dev; 82 struct net_device *netdev;
83 struct net_device *phys_dev; /* device with ethtool_ops */
84 struct fc_exch_mgr *oem; /* offload exchange manger */ 83 struct fc_exch_mgr *oem; /* offload exchange manger */
85 struct packet_type fcoe_packet_type; 84 struct packet_type fcoe_packet_type;
86 struct packet_type fip_packet_type; 85 struct packet_type fip_packet_type;
@@ -95,7 +94,7 @@ struct fcoe_softc {
95static inline struct net_device *fcoe_netdev( 94static inline struct net_device *fcoe_netdev(
96 const struct fc_lport *lp) 95 const struct fc_lport *lp)
97{ 96{
98 return ((struct fcoe_softc *)lport_priv(lp))->real_dev; 97 return ((struct fcoe_softc *)lport_priv(lp))->netdev;
99} 98}
100 99
101#endif /* _FCOE_H_ */ 100#endif /* _FCOE_H_ */