aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorChris Leech <christopher.leech@intel.com>2009-08-25 16:59:46 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-09-10 13:07:33 -0400
commit3fe9a0badae7fa2eb35eff4f07e851fbd25e3d4f (patch)
tree0ba5615fc7b696b6489b8417a2a5c9915bdf1d4c /drivers/scsi
parent259ad85d8dbbcd508e3dad29a36e3e76365853b7 (diff)
[SCSI] fcoe: move FIP controller from fcoe_port to fcoe_interface
There is only one FIP state per net_device, so the FIP controller needs to be moved from the per-SCSI-host fcoe_port to the per-net_device fcoe_interface structure. Signed-off-by: Chris Leech <christopher.leech@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/fcoe/fcoe.c83
-rw-r--r--drivers/scsi/fcoe/fcoe.h4
2 files changed, 39 insertions, 48 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index c215235ee39..01519c722ed 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -152,11 +152,9 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev,
152 struct net_device *orig_dev) 152 struct net_device *orig_dev)
153{ 153{
154 struct fcoe_interface *fcoe; 154 struct fcoe_interface *fcoe;
155 struct fcoe_port *port;
156 155
157 fcoe = container_of(ptype, struct fcoe_interface, fip_packet_type); 156 fcoe = container_of(ptype, struct fcoe_interface, fip_packet_type);
158 port = fcoe->priv; 157 fcoe_ctlr_recv(&fcoe->ctlr, skb);
159 fcoe_ctlr_recv(&port->ctlr, skb);
160 return 0; 158 return 0;
161} 159}
162 160
@@ -167,7 +165,7 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev,
167 */ 165 */
168static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb) 166static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
169{ 167{
170 skb->dev = fcoe_from_ctlr(fip)->fcoe->netdev; 168 skb->dev = fcoe_from_ctlr(fip)->netdev;
171 dev_queue_xmit(skb); 169 dev_queue_xmit(skb);
172} 170}
173 171
@@ -183,11 +181,8 @@ static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
183static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new) 181static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new)
184{ 182{
185 struct fcoe_interface *fcoe; 183 struct fcoe_interface *fcoe;
186 struct fcoe_port *port;
187
188 port = fcoe_from_ctlr(fip);
189 fcoe = port->fcoe;
190 184
185 fcoe = fcoe_from_ctlr(fip);
191 rtnl_lock(); 186 rtnl_lock();
192 if (!is_zero_ether_addr(old)) 187 if (!is_zero_ether_addr(old))
193 dev_unicast_delete(fcoe->netdev, old); 188 dev_unicast_delete(fcoe->netdev, old);
@@ -244,10 +239,10 @@ void fcoe_netdev_cleanup(struct fcoe_port *port)
244 rtnl_lock(); 239 rtnl_lock();
245 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); 240 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
246 dev_unicast_delete(fcoe->netdev, flogi_maddr); 241 dev_unicast_delete(fcoe->netdev, flogi_maddr);
247 if (!is_zero_ether_addr(port->ctlr.data_src_addr)) 242 if (!is_zero_ether_addr(fcoe->ctlr.data_src_addr))
248 dev_unicast_delete(fcoe->netdev, port->ctlr.data_src_addr); 243 dev_unicast_delete(fcoe->netdev, fcoe->ctlr.data_src_addr);
249 if (port->ctlr.spma) 244 if (fcoe->ctlr.spma)
250 dev_unicast_delete(fcoe->netdev, port->ctlr.ctl_src_addr); 245 dev_unicast_delete(fcoe->netdev, fcoe->ctlr.ctl_src_addr);
251 dev_mc_delete(fcoe->netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); 246 dev_mc_delete(fcoe->netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
252 rtnl_unlock(); 247 rtnl_unlock();
253} 248}
@@ -285,7 +280,7 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
285 /* Setup lport private data to point to fcoe softc */ 280 /* Setup lport private data to point to fcoe softc */
286 port = lport_priv(lp); 281 port = lport_priv(lp);
287 fcoe = port->fcoe; 282 fcoe = port->fcoe;
288 port->ctlr.lp = lp; 283 fcoe->ctlr.lp = lp;
289 fcoe->netdev = netdev; 284 fcoe->netdev = netdev;
290 285
291 /* Do not support for bonding device */ 286 /* Do not support for bonding device */
@@ -334,17 +329,17 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
334 rcu_read_lock(); 329 rcu_read_lock();
335 for_each_dev_addr(netdev, ha) { 330 for_each_dev_addr(netdev, ha) {
336 if ((ha->type == NETDEV_HW_ADDR_T_SAN) && 331 if ((ha->type == NETDEV_HW_ADDR_T_SAN) &&
337 (is_valid_ether_addr(port->ctlr.ctl_src_addr))) { 332 (is_valid_ether_addr(fcoe->ctlr.ctl_src_addr))) {
338 memcpy(port->ctlr.ctl_src_addr, ha->addr, ETH_ALEN); 333 memcpy(fcoe->ctlr.ctl_src_addr, ha->addr, ETH_ALEN);
339 port->ctlr.spma = 1; 334 fcoe->ctlr.spma = 1;
340 break; 335 break;
341 } 336 }
342 } 337 }
343 rcu_read_unlock(); 338 rcu_read_unlock();
344 339
345 /* setup Source Mac Address */ 340 /* setup Source Mac Address */
346 if (!port->ctlr.spma) 341 if (!fcoe->ctlr.spma)
347 memcpy(port->ctlr.ctl_src_addr, netdev->dev_addr, 342 memcpy(fcoe->ctlr.ctl_src_addr, netdev->dev_addr,
348 netdev->addr_len); 343 netdev->addr_len);
349 344
350 wwnn = fcoe_wwn_from_mac(netdev->dev_addr, 1, 0); 345 wwnn = fcoe_wwn_from_mac(netdev->dev_addr, 1, 0);
@@ -361,8 +356,8 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
361 rtnl_lock(); 356 rtnl_lock();
362 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); 357 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
363 dev_unicast_add(netdev, flogi_maddr); 358 dev_unicast_add(netdev, flogi_maddr);
364 if (port->ctlr.spma) 359 if (fcoe->ctlr.spma)
365 dev_unicast_add(netdev, port->ctlr.ctl_src_addr); 360 dev_unicast_add(netdev, fcoe->ctlr.ctl_src_addr);
366 dev_mc_add(netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); 361 dev_mc_add(netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
367 rtnl_unlock(); 362 rtnl_unlock();
368 363
@@ -537,7 +532,7 @@ static void fcoe_if_destroy(struct fc_lport *lport)
537 fcoe_netdev_cleanup(port); 532 fcoe_netdev_cleanup(port);
538 533
539 /* tear-down the FCoE controller */ 534 /* tear-down the FCoE controller */
540 fcoe_ctlr_destroy(&port->ctlr); 535 fcoe_ctlr_destroy(&fcoe->ctlr);
541 536
542 /* Free queued packets for the per-CPU receive threads */ 537 /* Free queued packets for the per-CPU receive threads */
543 fcoe_percpu_clean(lport); 538 fcoe_percpu_clean(lport);
@@ -662,9 +657,9 @@ static struct fc_lport *fcoe_if_create(struct net_device *netdev,
662 /* 657 /*
663 * Initialize FIP. 658 * Initialize FIP.
664 */ 659 */
665 fcoe_ctlr_init(&port->ctlr); 660 fcoe_ctlr_init(&fcoe->ctlr);
666 port->ctlr.send = fcoe_fip_send; 661 fcoe->ctlr.send = fcoe_fip_send;
667 port->ctlr.update_mac = fcoe_update_src_mac; 662 fcoe->ctlr.update_mac = fcoe_update_src_mac;
668 663
669 /* configure lport network properties */ 664 /* configure lport network properties */
670 rc = fcoe_netdev_config(lport, netdev); 665 rc = fcoe_netdev_config(lport, netdev);
@@ -714,7 +709,7 @@ static struct fc_lport *fcoe_if_create(struct net_device *netdev,
714 fc_fabric_login(lport); 709 fc_fabric_login(lport);
715 710
716 if (!fcoe_link_ok(lport)) 711 if (!fcoe_link_ok(lport))
717 fcoe_ctlr_link_up(&port->ctlr); 712 fcoe_ctlr_link_up(&fcoe->ctlr);
718 713
719 dev_hold(netdev); 714 dev_hold(netdev);
720 715
@@ -929,14 +924,12 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev,
929 struct fc_lport *lp; 924 struct fc_lport *lp;
930 struct fcoe_rcv_info *fr; 925 struct fcoe_rcv_info *fr;
931 struct fcoe_interface *fcoe; 926 struct fcoe_interface *fcoe;
932 struct fcoe_port *port;
933 struct fc_frame_header *fh; 927 struct fc_frame_header *fh;
934 struct fcoe_percpu_s *fps; 928 struct fcoe_percpu_s *fps;
935 unsigned int cpu; 929 unsigned int cpu;
936 930
937 fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type); 931 fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type);
938 port = fcoe->priv; 932 lp = fcoe->ctlr.lp;
939 lp = port->ctlr.lp;
940 if (unlikely(lp == NULL)) { 933 if (unlikely(lp == NULL)) {
941 FCOE_NETDEV_DBG(dev, "Cannot find hba structure"); 934 FCOE_NETDEV_DBG(dev, "Cannot find hba structure");
942 goto err2; 935 goto err2;
@@ -1137,13 +1130,13 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
1137 unsigned int hlen; /* header length implies the version */ 1130 unsigned int hlen; /* header length implies the version */
1138 unsigned int tlen; /* trailer length */ 1131 unsigned int tlen; /* trailer length */
1139 unsigned int elen; /* eth header, may include vlan */ 1132 unsigned int elen; /* eth header, may include vlan */
1140 struct fcoe_port *port; 1133 struct fcoe_port *port = lport_priv(lp);
1134 struct fcoe_interface *fcoe = port->fcoe;
1141 u8 sof, eof; 1135 u8 sof, eof;
1142 struct fcoe_hdr *hp; 1136 struct fcoe_hdr *hp;
1143 1137
1144 WARN_ON((fr_len(fp) % sizeof(u32)) != 0); 1138 WARN_ON((fr_len(fp) % sizeof(u32)) != 0);
1145 1139
1146 port = lport_priv(lp);
1147 fh = fc_frame_header_get(fp); 1140 fh = fc_frame_header_get(fp);
1148 skb = fp_skb(fp); 1141 skb = fp_skb(fp);
1149 wlen = skb->len / FCOE_WORD_TO_BYTE; 1142 wlen = skb->len / FCOE_WORD_TO_BYTE;
@@ -1154,7 +1147,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
1154 } 1147 }
1155 1148
1156 if (unlikely(fh->fh_r_ctl == FC_RCTL_ELS_REQ) && 1149 if (unlikely(fh->fh_r_ctl == FC_RCTL_ELS_REQ) &&
1157 fcoe_ctlr_els_send(&port->ctlr, skb)) 1150 fcoe_ctlr_els_send(&fcoe->ctlr, skb))
1158 return 0; 1151 return 0;
1159 1152
1160 sof = fr_sof(fp); 1153 sof = fr_sof(fp);
@@ -1205,21 +1198,21 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp)
1205 skb_reset_network_header(skb); 1198 skb_reset_network_header(skb);
1206 skb->mac_len = elen; 1199 skb->mac_len = elen;
1207 skb->protocol = htons(ETH_P_FCOE); 1200 skb->protocol = htons(ETH_P_FCOE);
1208 skb->dev = port->fcoe->netdev; 1201 skb->dev = fcoe->netdev;
1209 1202
1210 /* fill up mac and fcoe headers */ 1203 /* fill up mac and fcoe headers */
1211 eh = eth_hdr(skb); 1204 eh = eth_hdr(skb);
1212 eh->h_proto = htons(ETH_P_FCOE); 1205 eh->h_proto = htons(ETH_P_FCOE);
1213 if (port->ctlr.map_dest) 1206 if (fcoe->ctlr.map_dest)
1214 fc_fcoe_set_mac(eh->h_dest, fh->fh_d_id); 1207 fc_fcoe_set_mac(eh->h_dest, fh->fh_d_id);
1215 else 1208 else
1216 /* insert GW address */ 1209 /* insert GW address */
1217 memcpy(eh->h_dest, port->ctlr.dest_addr, ETH_ALEN); 1210 memcpy(eh->h_dest, fcoe->ctlr.dest_addr, ETH_ALEN);
1218 1211
1219 if (unlikely(port->ctlr.flogi_oxid != FC_XID_UNKNOWN)) 1212 if (unlikely(fcoe->ctlr.flogi_oxid != FC_XID_UNKNOWN))
1220 memcpy(eh->h_source, port->ctlr.ctl_src_addr, ETH_ALEN); 1213 memcpy(eh->h_source, fcoe->ctlr.ctl_src_addr, ETH_ALEN);
1221 else 1214 else
1222 memcpy(eh->h_source, port->ctlr.data_src_addr, ETH_ALEN); 1215 memcpy(eh->h_source, fcoe->ctlr.data_src_addr, ETH_ALEN);
1223 1216
1224 hp = (struct fcoe_hdr *)(eh + 1); 1217 hp = (struct fcoe_hdr *)(eh + 1);
1225 memset(hp, 0, sizeof(*hp)); 1218 memset(hp, 0, sizeof(*hp));
@@ -1382,8 +1375,8 @@ int fcoe_percpu_receive_thread(void *arg)
1382 } 1375 }
1383 fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED; 1376 fr_flags(fp) &= ~FCPHF_CRC_UNCHECKED;
1384 } 1377 }
1385 if (unlikely(port->ctlr.flogi_oxid != FC_XID_UNKNOWN) && 1378 if (unlikely(port->fcoe->ctlr.flogi_oxid != FC_XID_UNKNOWN) &&
1386 fcoe_ctlr_recv_flogi(&port->ctlr, fp, mac)) { 1379 fcoe_ctlr_recv_flogi(&port->fcoe->ctlr, fp, mac)) {
1387 fc_frame_free(fp); 1380 fc_frame_free(fp);
1388 continue; 1381 continue;
1389 } 1382 }
@@ -1482,7 +1475,6 @@ static int fcoe_device_notification(struct notifier_block *notifier,
1482 struct fc_lport *lp = NULL; 1475 struct fc_lport *lp = NULL;
1483 struct net_device *netdev = ptr; 1476 struct net_device *netdev = ptr;
1484 struct fcoe_interface *fcoe; 1477 struct fcoe_interface *fcoe;
1485 struct fcoe_port *port = NULL;
1486 struct fcoe_dev_stats *stats; 1478 struct fcoe_dev_stats *stats;
1487 u32 link_possible = 1; 1479 u32 link_possible = 1;
1488 u32 mfs; 1480 u32 mfs;
@@ -1490,9 +1482,8 @@ static int fcoe_device_notification(struct notifier_block *notifier,
1490 1482
1491 read_lock(&fcoe_hostlist_lock); 1483 read_lock(&fcoe_hostlist_lock);
1492 list_for_each_entry(fcoe, &fcoe_hostlist, list) { 1484 list_for_each_entry(fcoe, &fcoe_hostlist, list) {
1493 port = fcoe->priv;
1494 if (fcoe->netdev == netdev) { 1485 if (fcoe->netdev == netdev) {
1495 lp = port->ctlr.lp; 1486 lp = fcoe->ctlr.lp;
1496 break; 1487 break;
1497 } 1488 }
1498 } 1489 }
@@ -1523,8 +1514,8 @@ static int fcoe_device_notification(struct notifier_block *notifier,
1523 "from netdev netlink\n", event); 1514 "from netdev netlink\n", event);
1524 } 1515 }
1525 if (link_possible && !fcoe_link_ok(lp)) 1516 if (link_possible && !fcoe_link_ok(lp))
1526 fcoe_ctlr_link_up(&port->ctlr); 1517 fcoe_ctlr_link_up(&fcoe->ctlr);
1527 else if (fcoe_ctlr_link_down(&port->ctlr)) { 1518 else if (fcoe_ctlr_link_down(&fcoe->ctlr)) {
1528 stats = fc_lport_get_stats(lp); 1519 stats = fc_lport_get_stats(lp);
1529 stats->LinkFailureCount++; 1520 stats->LinkFailureCount++;
1530 fcoe_clean_pending_queue(lp); 1521 fcoe_clean_pending_queue(lp);
@@ -1841,7 +1832,7 @@ struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev)
1841 fcoe = fcoe_hostlist_lookup_port(netdev); 1832 fcoe = fcoe_hostlist_lookup_port(netdev);
1842 read_unlock(&fcoe_hostlist_lock); 1833 read_unlock(&fcoe_hostlist_lock);
1843 1834
1844 return (fcoe) ? fcoe->priv->ctlr.lp : NULL; 1835 return (fcoe) ? fcoe->ctlr.lp : NULL;
1845} 1836}
1846 1837
1847/** 1838/**
@@ -1941,7 +1932,7 @@ static void __exit fcoe_exit(void)
1941 1932
1942 /* releases the associated fcoe hosts */ 1933 /* releases the associated fcoe hosts */
1943 list_for_each_entry_safe(fcoe, tmp, &fcoe_hostlist, list) 1934 list_for_each_entry_safe(fcoe, tmp, &fcoe_hostlist, list)
1944 fcoe_if_destroy(fcoe->priv->ctlr.lp); 1935 fcoe_if_destroy(fcoe->ctlr.lp);
1945 1936
1946 unregister_hotcpu_notifier(&fcoe_cpu_notifier); 1937 unregister_hotcpu_notifier(&fcoe_cpu_notifier);
1947 1938
diff --git a/drivers/scsi/fcoe/fcoe.h b/drivers/scsi/fcoe/fcoe.h
index 685aa9d0222..5b190b5fea3 100644
--- a/drivers/scsi/fcoe/fcoe.h
+++ b/drivers/scsi/fcoe/fcoe.h
@@ -85,6 +85,7 @@ struct fcoe_interface {
85 struct net_device *netdev; 85 struct net_device *netdev;
86 struct packet_type fcoe_packet_type; 86 struct packet_type fcoe_packet_type;
87 struct packet_type fip_packet_type; 87 struct packet_type fip_packet_type;
88 struct fcoe_ctlr ctlr;
88}; 89};
89 90
90/* 91/*
@@ -97,10 +98,9 @@ struct fcoe_port {
97 struct sk_buff_head fcoe_pending_queue; 98 struct sk_buff_head fcoe_pending_queue;
98 u8 fcoe_pending_queue_active; 99 u8 fcoe_pending_queue_active;
99 struct timer_list timer; /* queue timer */ 100 struct timer_list timer; /* queue timer */
100 struct fcoe_ctlr ctlr;
101}; 101};
102 102
103#define fcoe_from_ctlr(fip) container_of(fip, struct fcoe_port, ctlr) 103#define fcoe_from_ctlr(fip) container_of(fip, struct fcoe_interface, ctlr)
104 104
105static inline struct net_device *fcoe_netdev(const struct fc_lport *lp) 105static inline struct net_device *fcoe_netdev(const struct fc_lport *lp)
106{ 106{