[Open-FCoE] [PATCH V5 07/16] fcoe: move packet handlers from fcoe_port to fcoe_interface

Chris Leech christopher.leech at intel.com
Mon Jul 27 16:28:44 UTC 2009


The packet handlers need to be tracked in fcoe_interface so there is only one
set per net_device.  When NPIV is enabled there will be multiple SCSI hosts
and multiple fcoe_port structures on a single net_device.

The packet handlers match by ethertype and netdev.  If the same handler gets
registered on a single netdev multiple times, the receive function will be
called multiple times for each frame.

Signed-off-by: Chris Leech <christopher.leech at intel.com>
---

 drivers/scsi/fcoe/fcoe.c |   28 ++++++++++++++++------------
 drivers/scsi/fcoe/fcoe.h |    4 ++--
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 6c3cdb3..3b919b7 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -152,9 +152,11 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev,
 			 struct packet_type *ptype,
 			 struct net_device *orig_dev)
 {
+	struct fcoe_interface *fcoe;
 	struct fcoe_port *port;
 
-	port = container_of(ptype, struct fcoe_port, fip_packet_type);
+	fcoe = container_of(ptype, struct fcoe_interface, fip_packet_type);
+	port = fcoe->priv;
 	fcoe_ctlr_recv(&port->ctlr, skb);
 	return 0;
 }
@@ -236,8 +238,8 @@ void fcoe_netdev_cleanup(struct fcoe_port *port)
 	struct fcoe_interface *fcoe = port->fcoe;
 
 	/* Don't listen for Ethernet packets anymore */
-	dev_remove_pack(&port->fcoe_packet_type);
-	dev_remove_pack(&port->fip_packet_type);
+	dev_remove_pack(&fcoe->fcoe_packet_type);
+	dev_remove_pack(&fcoe->fip_packet_type);
 
 	/* Delete secondary MAC addresses */
 	rtnl_lock();
@@ -369,15 +371,15 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
 	 * setup the receive function from ethernet driver
 	 * on the ethertype for the given device
 	 */
-	port->fcoe_packet_type.func = fcoe_rcv;
-	port->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE);
-	port->fcoe_packet_type.dev = netdev;
-	dev_add_pack(&port->fcoe_packet_type);
+	fcoe->fcoe_packet_type.func = fcoe_rcv;
+	fcoe->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE);
+	fcoe->fcoe_packet_type.dev = netdev;
+	dev_add_pack(&fcoe->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 = netdev;
-	dev_add_pack(&port->fip_packet_type);
+	fcoe->fip_packet_type.func = fcoe_fip_recv;
+	fcoe->fip_packet_type.type = htons(ETH_P_FIP);
+	fcoe->fip_packet_type.dev = netdev;
+	dev_add_pack(&fcoe->fip_packet_type);
 
 	return 0;
 }
@@ -927,13 +929,15 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev,
 {
 	struct fc_lport *lp;
 	struct fcoe_rcv_info *fr;
+	struct fcoe_interface *fcoe;
 	struct fcoe_port *port;
 	struct fc_frame_header *fh;
 	struct fcoe_percpu_s *fps;
 	unsigned short oxid;
 	unsigned int cpu = 0;
 
-	port = container_of(ptype, struct fcoe_port, fcoe_packet_type);
+	fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type);
+	port = fcoe->priv;
 	lp = port->ctlr.lp;
 	if (unlikely(lp == NULL)) {
 		FCOE_NETDEV_DBG(dev, "Cannot find hba structure");
diff --git a/drivers/scsi/fcoe/fcoe.h b/drivers/scsi/fcoe/fcoe.h
index bd9d313..5cf093d 100644
--- a/drivers/scsi/fcoe/fcoe.h
+++ b/drivers/scsi/fcoe/fcoe.h
@@ -83,6 +83,8 @@ struct fcoe_interface {
 	 * moved out of fcoe_port */
 	struct fcoe_port *priv;
 	struct net_device *netdev;
+	struct packet_type  fcoe_packet_type;
+	struct packet_type  fip_packet_type;
 };
 
 /*
@@ -92,8 +94,6 @@ struct fcoe_interface {
 struct fcoe_port {
 	struct fcoe_interface *fcoe;
 	struct fc_exch_mgr *oem;		/* offload exchange manger */
-	struct packet_type  fcoe_packet_type;
-	struct packet_type  fip_packet_type;
 	struct sk_buff_head fcoe_pending_queue;
 	u8	fcoe_pending_queue_active;
 	struct timer_list timer;		/* queue timer */




More information about the devel mailing list