Commit 619fe4bed415e5d8a4749937f42b6a8a9031d4aa

Authored by Robert Love
Committed by James Bottomley
1 parent b7e94a1686

[SCSI] 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_device instance.
The problem is that libfcoe wants to be able use pointer math to find a
fcoe_ctlr's fcoe_ctlr_device as well as finding a fcoe_ctlr_device's
assocated fcoe_ctlr. To do this we need to allocate the
fcoe_ctlr_device, with private data for the LLD. The private data
contains the fcoe_ctlr and its private data is the fcoe_interface.
This patch only allocates the fcoe_interface with the fcoe_ctlr, the
fcoe_ctlr_device will be added in a later patch, which will complete
the below diagram-

+------------------+
| fcoe_ctlr_device |
+------------------+
| fcoe_ctlr        |
+------------------+
| fcoe_interface   |
+------------------+

This prep work will allow us to go from a fcoe_ctlr_device instance
to its fcoe_ctlr as well as from a fcoe_ctlr to its fcoe_ctlr_device
once the fcoe_sysfs API is in use (later patches in this series).

Signed-off-by: Robert Love <robert.w.love@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

Showing 3 changed files with 102 additions and 52 deletions Side-by-side Diff

drivers/scsi/fcoe/fcoe.c
... ... @@ -282,7 +282,7 @@
282 282 static int fcoe_interface_setup(struct fcoe_interface *fcoe,
283 283 struct net_device *netdev)
284 284 {
285   - struct fcoe_ctlr *fip = &fcoe->ctlr;
  285 + struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
286 286 struct netdev_hw_addr *ha;
287 287 struct net_device *real_dev;
288 288 u8 flogi_maddr[ETH_ALEN];
289 289  
... ... @@ -366,7 +366,9 @@
366 366 static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,
367 367 enum fip_state fip_mode)
368 368 {
  369 + struct fcoe_ctlr *ctlr;
369 370 struct fcoe_interface *fcoe;
  371 + int size;
370 372 int err;
371 373  
372 374 if (!try_module_get(THIS_MODULE)) {
... ... @@ -376,7 +378,9 @@
376 378 goto out;
377 379 }
378 380  
379   - fcoe = kzalloc(sizeof(*fcoe), GFP_KERNEL);
  381 + size = sizeof(struct fcoe_ctlr) + sizeof(struct fcoe_interface);
  382 + ctlr = kzalloc(size, GFP_KERNEL);
  383 + fcoe = fcoe_ctlr_priv(ctlr);
380 384 if (!fcoe) {
381 385 FCOE_NETDEV_DBG(netdev, "Could not allocate fcoe structure\n");
382 386 fcoe = ERR_PTR(-ENOMEM);
383 387  
... ... @@ -388,15 +392,14 @@
388 392 /*
389 393 * Initialize FIP.
390 394 */
391   - fcoe_ctlr_init(&fcoe->ctlr, fip_mode);
392   - fcoe->ctlr.send = fcoe_fip_send;
393   - fcoe->ctlr.update_mac = fcoe_update_src_mac;
394   - fcoe->ctlr.get_src_addr = fcoe_get_src_mac;
  395 + fcoe_ctlr_init(ctlr, fip_mode);
  396 + ctlr->send = fcoe_fip_send;
  397 + ctlr->update_mac = fcoe_update_src_mac;
  398 + ctlr->get_src_addr = fcoe_get_src_mac;
395 399  
396 400 err = fcoe_interface_setup(fcoe, netdev);
397 401 if (err) {
398   - fcoe_ctlr_destroy(&fcoe->ctlr);
399   - kfree(fcoe);
  402 + fcoe_ctlr_destroy(ctlr);
400 403 dev_put(netdev);
401 404 fcoe = ERR_PTR(err);
402 405 goto out_putmod;
... ... @@ -419,7 +422,7 @@
419 422 static void fcoe_interface_remove(struct fcoe_interface *fcoe)
420 423 {
421 424 struct net_device *netdev = fcoe->netdev;
422   - struct fcoe_ctlr *fip = &fcoe->ctlr;
  425 + struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
423 426 u8 flogi_maddr[ETH_ALEN];
424 427 const struct net_device_ops *ops;
425 428  
... ... @@ -462,7 +465,7 @@
462 465 static void fcoe_interface_cleanup(struct fcoe_interface *fcoe)
463 466 {
464 467 struct net_device *netdev = fcoe->netdev;
465   - struct fcoe_ctlr *fip = &fcoe->ctlr;
  468 + struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
466 469  
467 470 rtnl_lock();
468 471 if (!fcoe->removed)
... ... @@ -472,8 +475,8 @@
472 475 /* Release the self-reference taken during fcoe_interface_create() */
473 476 /* tear-down the FCoE controller */
474 477 fcoe_ctlr_destroy(fip);
475   - scsi_host_put(fcoe->ctlr.lp->host);
476   - kfree(fcoe);
  478 + scsi_host_put(fip->lp->host);
  479 + kfree(fip);
477 480 dev_put(netdev);
478 481 module_put(THIS_MODULE);
479 482 }
480 483  
... ... @@ -493,9 +496,11 @@
493 496 struct net_device *orig_dev)
494 497 {
495 498 struct fcoe_interface *fcoe;
  499 + struct fcoe_ctlr *ctlr;
496 500  
497 501 fcoe = container_of(ptype, struct fcoe_interface, fip_packet_type);
498   - fcoe_ctlr_recv(&fcoe->ctlr, skb);
  502 + ctlr = fcoe_to_ctlr(fcoe);
  503 + fcoe_ctlr_recv(ctlr, skb);
499 504 return 0;
500 505 }
501 506  
502 507  
... ... @@ -645,11 +650,13 @@
645 650 u32 mfs;
646 651 u64 wwnn, wwpn;
647 652 struct fcoe_interface *fcoe;
  653 + struct fcoe_ctlr *ctlr;
648 654 struct fcoe_port *port;
649 655  
650 656 /* Setup lport private data to point to fcoe softc */
651 657 port = lport_priv(lport);
652 658 fcoe = port->priv;
  659 + ctlr = fcoe_to_ctlr(fcoe);
653 660  
654 661 /*
655 662 * Determine max frame size based on underlying device and optional
656 663  
... ... @@ -676,10 +683,10 @@
676 683  
677 684 if (!lport->vport) {
678 685 if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN))
679   - wwnn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 1, 0);
  686 + wwnn = fcoe_wwn_from_mac(ctlr->ctl_src_addr, 1, 0);
680 687 fc_set_wwnn(lport, wwnn);
681 688 if (fcoe_get_wwn(netdev, &wwpn, NETDEV_FCOE_WWPN))
682   - wwpn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr,
  689 + wwpn = fcoe_wwn_from_mac(ctlr->ctl_src_addr,
683 690 2, 0);
684 691 fc_set_wwpn(lport, wwpn);
685 692 }
... ... @@ -1056,6 +1063,7 @@
1056 1063 static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
1057 1064 struct device *parent, int npiv)
1058 1065 {
  1066 + struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
1059 1067 struct net_device *netdev = fcoe->netdev;
1060 1068 struct fc_lport *lport, *n_port;
1061 1069 struct fcoe_port *port;
... ... @@ -1119,7 +1127,7 @@
1119 1127 }
1120 1128  
1121 1129 /* Initialize the library */
1122   - rc = fcoe_libfc_config(lport, &fcoe->ctlr, &fcoe_libfc_fcn_templ, 1);
  1130 + rc = fcoe_libfc_config(lport, ctlr, &fcoe_libfc_fcn_templ, 1);
1123 1131 if (rc) {
1124 1132 FCOE_NETDEV_DBG(netdev, "Could not configure libfc for the "
1125 1133 "interface\n");
... ... @@ -1386,6 +1394,7 @@
1386 1394 {
1387 1395 struct fc_lport *lport;
1388 1396 struct fcoe_rcv_info *fr;
  1397 + struct fcoe_ctlr *ctlr;
1389 1398 struct fcoe_interface *fcoe;
1390 1399 struct fc_frame_header *fh;
1391 1400 struct fcoe_percpu_s *fps;
... ... @@ -1393,7 +1402,8 @@
1393 1402 unsigned int cpu;
1394 1403  
1395 1404 fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type);
1396   - lport = fcoe->ctlr.lp;
  1405 + ctlr = fcoe_to_ctlr(fcoe);
  1406 + lport = ctlr->lp;
1397 1407 if (unlikely(!lport)) {
1398 1408 FCOE_NETDEV_DBG(netdev, "Cannot find hba structure");
1399 1409 goto err2;
... ... @@ -1409,8 +1419,8 @@
1409 1419  
1410 1420 eh = eth_hdr(skb);
1411 1421  
1412   - if (is_fip_mode(&fcoe->ctlr) &&
1413   - compare_ether_addr(eh->h_source, fcoe->ctlr.dest_addr)) {
  1422 + if (is_fip_mode(ctlr) &&
  1423 + compare_ether_addr(eh->h_source, ctlr->dest_addr)) {
1414 1424 FCOE_NETDEV_DBG(netdev, "wrong source mac address:%pM\n",
1415 1425 eh->h_source);
1416 1426 goto err;
... ... @@ -1544,6 +1554,7 @@
1544 1554 unsigned int elen; /* eth header, may include vlan */
1545 1555 struct fcoe_port *port = lport_priv(lport);
1546 1556 struct fcoe_interface *fcoe = port->priv;
  1557 + struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
1547 1558 u8 sof, eof;
1548 1559 struct fcoe_hdr *hp;
1549 1560  
... ... @@ -1559,7 +1570,7 @@
1559 1570 }
1560 1571  
1561 1572 if (unlikely(fh->fh_type == FC_TYPE_ELS) &&
1562   - fcoe_ctlr_els_send(&fcoe->ctlr, lport, skb))
  1573 + fcoe_ctlr_els_send(ctlr, lport, skb))
1563 1574 return 0;
1564 1575  
1565 1576 sof = fr_sof(fp);
1566 1577  
... ... @@ -1623,12 +1634,12 @@
1623 1634 /* fill up mac and fcoe headers */
1624 1635 eh = eth_hdr(skb);
1625 1636 eh->h_proto = htons(ETH_P_FCOE);
1626   - memcpy(eh->h_dest, fcoe->ctlr.dest_addr, ETH_ALEN);
1627   - if (fcoe->ctlr.map_dest)
  1637 + memcpy(eh->h_dest, ctlr->dest_addr, ETH_ALEN);
  1638 + if (ctlr->map_dest)
1628 1639 memcpy(eh->h_dest + 3, fh->fh_d_id, 3);
1629 1640  
1630   - if (unlikely(fcoe->ctlr.flogi_oxid != FC_XID_UNKNOWN))
1631   - memcpy(eh->h_source, fcoe->ctlr.ctl_src_addr, ETH_ALEN);
  1641 + if (unlikely(ctlr->flogi_oxid != FC_XID_UNKNOWN))
  1642 + memcpy(eh->h_source, ctlr->ctl_src_addr, ETH_ALEN);
1632 1643 else
1633 1644 memcpy(eh->h_source, port->data_src_addr, ETH_ALEN);
1634 1645  
... ... @@ -1677,6 +1688,7 @@
1677 1688 static inline int fcoe_filter_frames(struct fc_lport *lport,
1678 1689 struct fc_frame *fp)
1679 1690 {
  1691 + struct fcoe_ctlr *ctlr;
1680 1692 struct fcoe_interface *fcoe;
1681 1693 struct fc_frame_header *fh;
1682 1694 struct sk_buff *skb = (struct sk_buff *)fp;
... ... @@ -1698,7 +1710,8 @@
1698 1710 return 0;
1699 1711  
1700 1712 fcoe = ((struct fcoe_port *)lport_priv(lport))->priv;
1701   - if (is_fip_mode(&fcoe->ctlr) && fc_frame_payload_op(fp) == ELS_LOGO &&
  1713 + ctlr = fcoe_to_ctlr(fcoe);
  1714 + if (is_fip_mode(ctlr) && fc_frame_payload_op(fp) == ELS_LOGO &&
1702 1715 ntoh24(fh->fh_s_id) == FC_FID_FLOGI) {
1703 1716 FCOE_DBG("fcoe: dropping FCoE lport LOGO in fip mode\n");
1704 1717 return -EINVAL;
... ... @@ -1877,6 +1890,7 @@
1877 1890 ulong event, void *ptr)
1878 1891 {
1879 1892 struct dcb_app_type *entry = ptr;
  1893 + struct fcoe_ctlr *ctlr;
1880 1894 struct fcoe_interface *fcoe;
1881 1895 struct net_device *netdev;
1882 1896 struct fcoe_port *port;
... ... @@ -1894,6 +1908,8 @@
1894 1908 if (!fcoe)
1895 1909 return NOTIFY_OK;
1896 1910  
  1911 + ctlr = fcoe_to_ctlr(fcoe);
  1912 +
1897 1913 if (entry->dcbx & DCB_CAP_DCBX_VER_CEE)
1898 1914 prio = ffs(entry->app.priority) - 1;
1899 1915 else
1900 1916  
... ... @@ -1904,10 +1920,10 @@
1904 1920  
1905 1921 if (entry->app.protocol == ETH_P_FIP ||
1906 1922 entry->app.protocol == ETH_P_FCOE)
1907   - fcoe->ctlr.priority = prio;
  1923 + ctlr->priority = prio;
1908 1924  
1909 1925 if (entry->app.protocol == ETH_P_FCOE) {
1910   - port = lport_priv(fcoe->ctlr.lp);
  1926 + port = lport_priv(ctlr->lp);
1911 1927 port->priority = prio;
1912 1928 }
1913 1929  
... ... @@ -1929,6 +1945,7 @@
1929 1945 {
1930 1946 struct fc_lport *lport = NULL;
1931 1947 struct net_device *netdev = ptr;
  1948 + struct fcoe_ctlr *ctlr;
1932 1949 struct fcoe_interface *fcoe;
1933 1950 struct fcoe_port *port;
1934 1951 struct fcoe_dev_stats *stats;
... ... @@ -1938,7 +1955,8 @@
1938 1955  
1939 1956 list_for_each_entry(fcoe, &fcoe_hostlist, list) {
1940 1957 if (fcoe->netdev == netdev) {
1941   - lport = fcoe->ctlr.lp;
  1958 + ctlr = fcoe_to_ctlr(fcoe);
  1959 + lport = ctlr->lp;
1942 1960 break;
1943 1961 }
1944 1962 }
... ... @@ -1967,7 +1985,7 @@
1967 1985 break;
1968 1986 case NETDEV_UNREGISTER:
1969 1987 list_del(&fcoe->list);
1970   - port = lport_priv(fcoe->ctlr.lp);
  1988 + port = lport_priv(ctlr->lp);
1971 1989 queue_work(fcoe_wq, &port->destroy_work);
1972 1990 goto out;
1973 1991 break;
... ... @@ -1982,8 +2000,8 @@
1982 2000 fcoe_link_speed_update(lport);
1983 2001  
1984 2002 if (link_possible && !fcoe_link_ok(lport))
1985   - fcoe_ctlr_link_up(&fcoe->ctlr);
1986   - else if (fcoe_ctlr_link_down(&fcoe->ctlr)) {
  2003 + fcoe_ctlr_link_up(ctlr);
  2004 + else if (fcoe_ctlr_link_down(ctlr)) {
1987 2005 stats = per_cpu_ptr(lport->dev_stats, get_cpu());
1988 2006 stats->LinkFailureCount++;
1989 2007 put_cpu();
... ... @@ -2003,6 +2021,7 @@
2003 2021 */
2004 2022 static int fcoe_disable(struct net_device *netdev)
2005 2023 {
  2024 + struct fcoe_ctlr *ctlr;
2006 2025 struct fcoe_interface *fcoe;
2007 2026 int rc = 0;
2008 2027  
... ... @@ -2013,8 +2032,9 @@
2013 2032 rtnl_unlock();
2014 2033  
2015 2034 if (fcoe) {
2016   - fcoe_ctlr_link_down(&fcoe->ctlr);
2017   - fcoe_clean_pending_queue(fcoe->ctlr.lp);
  2035 + ctlr = fcoe_to_ctlr(fcoe);
  2036 + fcoe_ctlr_link_down(ctlr);
  2037 + fcoe_clean_pending_queue(ctlr->lp);
2018 2038 } else
2019 2039 rc = -ENODEV;
2020 2040  
... ... @@ -2032,6 +2052,7 @@
2032 2052 */
2033 2053 static int fcoe_enable(struct net_device *netdev)
2034 2054 {
  2055 + struct fcoe_ctlr *ctlr;
2035 2056 struct fcoe_interface *fcoe;
2036 2057 int rc = 0;
2037 2058  
2038 2059  
2039 2060  
... ... @@ -2040,11 +2061,17 @@
2040 2061 fcoe = fcoe_hostlist_lookup_port(netdev);
2041 2062 rtnl_unlock();
2042 2063  
2043   - if (!fcoe)
  2064 + if (!fcoe) {
2044 2065 rc = -ENODEV;
2045   - else if (!fcoe_link_ok(fcoe->ctlr.lp))
2046   - fcoe_ctlr_link_up(&fcoe->ctlr);
  2066 + goto out;
  2067 + }
2047 2068  
  2069 + ctlr = fcoe_to_ctlr(fcoe);
  2070 +
  2071 + if (!fcoe_link_ok(ctlr->lp))
  2072 + fcoe_ctlr_link_up(ctlr);
  2073 +
  2074 +out:
2048 2075 mutex_unlock(&fcoe_config_mutex);
2049 2076 return rc;
2050 2077 }
... ... @@ -2059,6 +2086,7 @@
2059 2086 */
2060 2087 static int fcoe_destroy(struct net_device *netdev)
2061 2088 {
  2089 + struct fcoe_ctlr *ctlr;
2062 2090 struct fcoe_interface *fcoe;
2063 2091 struct fc_lport *lport;
2064 2092 struct fcoe_port *port;
... ... @@ -2071,7 +2099,8 @@
2071 2099 rc = -ENODEV;
2072 2100 goto out_nodev;
2073 2101 }
2074   - lport = fcoe->ctlr.lp;
  2102 + ctlr = fcoe_to_ctlr(fcoe);
  2103 + lport = ctlr->lp;
2075 2104 port = lport_priv(lport);
2076 2105 list_del(&fcoe->list);
2077 2106 queue_work(fcoe_wq, &port->destroy_work);
... ... @@ -2126,7 +2155,8 @@
2126 2155 int dcbx;
2127 2156 u8 fup, up;
2128 2157 struct net_device *netdev = fcoe->realdev;
2129   - struct fcoe_port *port = lport_priv(fcoe->ctlr.lp);
  2158 + struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
  2159 + struct fcoe_port *port = lport_priv(ctlr->lp);
2130 2160 struct dcb_app app = {
2131 2161 .priority = 0,
2132 2162 .protocol = ETH_P_FCOE
... ... @@ -2149,7 +2179,7 @@
2149 2179 }
2150 2180  
2151 2181 port->priority = ffs(up) ? ffs(up) - 1 : 0;
2152   - fcoe->ctlr.priority = ffs(fup) ? ffs(fup) - 1 : port->priority;
  2182 + ctlr->priority = ffs(fup) ? ffs(fup) - 1 : port->priority;
2153 2183 }
2154 2184 #endif
2155 2185 }
... ... @@ -2166,6 +2196,7 @@
2166 2196 static int fcoe_create(struct net_device *netdev, enum fip_state fip_mode)
2167 2197 {
2168 2198 int rc = 0;
  2199 + struct fcoe_ctlr *ctlr;
2169 2200 struct fcoe_interface *fcoe;
2170 2201 struct fc_lport *lport;
2171 2202  
... ... @@ -2184,6 +2215,8 @@
2184 2215 goto out_nodev;
2185 2216 }
2186 2217  
  2218 + ctlr = fcoe_to_ctlr(fcoe);
  2219 +
2187 2220 lport = fcoe_if_create(fcoe, &netdev->dev, 0);
2188 2221 if (IS_ERR(lport)) {
2189 2222 printk(KERN_ERR "fcoe: Failed to create interface (%s)\n",
... ... @@ -2195,7 +2228,7 @@
2195 2228 }
2196 2229  
2197 2230 /* Make this the "master" N_Port */
2198   - fcoe->ctlr.lp = lport;
  2231 + ctlr->lp = lport;
2199 2232  
2200 2233 /* setup DCB priority attributes. */
2201 2234 fcoe_dcb_create(fcoe);
... ... @@ -2208,7 +2241,7 @@
2208 2241 fc_fabric_login(lport);
2209 2242 if (!fcoe_link_ok(lport)) {
2210 2243 rtnl_unlock();
2211   - fcoe_ctlr_link_up(&fcoe->ctlr);
  2244 + fcoe_ctlr_link_up(ctlr);
2212 2245 mutex_unlock(&fcoe_config_mutex);
2213 2246 return rc;
2214 2247 }
2215 2248  
... ... @@ -2320,11 +2353,12 @@
2320 2353 struct fc_lport *lport = shost_priv(shost);
2321 2354 struct fcoe_port *port = lport_priv(lport);
2322 2355 struct fcoe_interface *fcoe = port->priv;
  2356 + struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
2323 2357  
2324   - fcoe_ctlr_link_down(&fcoe->ctlr);
2325   - fcoe_clean_pending_queue(fcoe->ctlr.lp);
2326   - if (!fcoe_link_ok(fcoe->ctlr.lp))
2327   - fcoe_ctlr_link_up(&fcoe->ctlr);
  2358 + fcoe_ctlr_link_down(ctlr);
  2359 + fcoe_clean_pending_queue(ctlr->lp);
  2360 + if (!fcoe_link_ok(ctlr->lp))
  2361 + fcoe_ctlr_link_up(ctlr);
2328 2362 return 0;
2329 2363 }
2330 2364  
2331 2365  
... ... @@ -2359,10 +2393,12 @@
2359 2393 */
2360 2394 static struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
2361 2395 {
  2396 + struct fcoe_ctlr *ctlr;
2362 2397 struct fcoe_interface *fcoe;
2363 2398  
2364 2399 fcoe = fcoe_hostlist_lookup_port(netdev);
2365   - return (fcoe) ? fcoe->ctlr.lp : NULL;
  2400 + ctlr = fcoe_to_ctlr(fcoe);
  2401 + return (fcoe) ? ctlr->lp : NULL;
2366 2402 }
2367 2403  
2368 2404 /**
... ... @@ -2466,6 +2502,7 @@
2466 2502 static void __exit fcoe_exit(void)
2467 2503 {
2468 2504 struct fcoe_interface *fcoe, *tmp;
  2505 + struct fcoe_ctlr *ctlr;
2469 2506 struct fcoe_port *port;
2470 2507 unsigned int cpu;
2471 2508  
... ... @@ -2477,7 +2514,8 @@
2477 2514 rtnl_lock();
2478 2515 list_for_each_entry_safe(fcoe, tmp, &fcoe_hostlist, list) {
2479 2516 list_del(&fcoe->list);
2480   - port = lport_priv(fcoe->ctlr.lp);
  2517 + ctlr = fcoe_to_ctlr(fcoe);
  2518 + port = lport_priv(ctlr->lp);
2481 2519 queue_work(fcoe_wq, &port->destroy_work);
2482 2520 }
2483 2521 rtnl_unlock();
... ... @@ -2573,7 +2611,7 @@
2573 2611 {
2574 2612 struct fcoe_port *port = lport_priv(lport);
2575 2613 struct fcoe_interface *fcoe = port->priv;
2576   - struct fcoe_ctlr *fip = &fcoe->ctlr;
  2614 + struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
2577 2615 struct fc_frame_header *fh = fc_frame_header_get(fp);
2578 2616  
2579 2617 switch (op) {
2580 2618  
... ... @@ -2747,8 +2785,9 @@
2747 2785 {
2748 2786 struct fcoe_port *port = lport_priv(lport);
2749 2787 struct fcoe_interface *fcoe = port->priv;
  2788 + struct fcoe_ctlr *ctlr = fcoe_to_ctlr(fcoe);
2750 2789  
2751 2790 if (fp && fc_frame_payload_op(fp) == ELS_FLOGI)
2752   - fcoe_ctlr_recv_flogi(&fcoe->ctlr, lport, fp);
  2791 + fcoe_ctlr_recv_flogi(ctlr, lport, fp);
2753 2792 }
drivers/scsi/fcoe/fcoe.h
... ... @@ -68,7 +68,6 @@
68 68 * @netdev: The associated net device
69 69 * @fcoe_packet_type: FCoE packet type
70 70 * @fip_packet_type: FIP packet type
71   - * @ctlr: The FCoE controller (for FIP)
72 71 * @oem: The offload exchange manager for all local port
73 72 * instances associated with this port
74 73 * @removed: Indicates fcoe interface removed from net device
75 74  
... ... @@ -80,12 +79,15 @@
80 79 struct net_device *realdev;
81 80 struct packet_type fcoe_packet_type;
82 81 struct packet_type fip_packet_type;
83   - struct fcoe_ctlr ctlr;
84 82 struct fc_exch_mgr *oem;
85 83 u8 removed;
86 84 };
87 85  
88   -#define fcoe_from_ctlr(fip) container_of(fip, struct fcoe_interface, ctlr)
  86 +#define fcoe_to_ctlr(x) \
  87 + (struct fcoe_ctlr *)(((struct fcoe_ctlr *)(x)) - 1)
  88 +
  89 +#define fcoe_from_ctlr(x) \
  90 + ((struct fcoe_interface *)((x) + 1))
89 91  
90 92 /**
91 93 * fcoe_netdev() - Return the net device associated with a local port
include/scsi/libfcoe.h
... ... @@ -159,6 +159,15 @@
159 159 };
160 160  
161 161 /**
  162 + * fcoe_ctlr_priv() - Return the private data from a fcoe_ctlr
  163 + * @cltr: The fcoe_ctlr whose private data will be returned
  164 + */
  165 +static inline void *fcoe_ctlr_priv(const struct fcoe_ctlr *ctlr)
  166 +{
  167 + return (void *)(ctlr + 1);
  168 +}
  169 +
  170 +/**
162 171 * struct fcoe_fcf - Fibre-Channel Forwarder
163 172 * @list: list linkage
164 173 * @time: system time (jiffies) when an advertisement was last received