Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 150246
b: refs/heads/master
c: ab6b85c
h: refs/heads/master
v: v3
  • Loading branch information
Vasu Dev authored and David S. Miller committed May 18, 2009
1 parent c0484fa commit 33f6ed0
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 80 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aca6bee75fe53ae019b9cabff42095dfb6471fde
refs/heads/master: ab6b85c1d7a1bf6c2b27fb542a7b2404e45b7e24
173 changes: 94 additions & 79 deletions trunk/drivers/scsi/fcoe/fcoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,58 @@ static struct scsi_host_template fcoe_shost_template = {
.max_sectors = 0xffff,
};

/**
* fcoe_fip_recv - handle a received FIP frame.
* @skb: the receive skb
* @dev: associated &net_device
* @ptype: the &packet_type structure which was used to register this handler.
* @orig_dev: original receive &net_device, in case @dev is a bond.
*
* Returns: 0 for success
*/
static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
struct net_device *orig_dev)
{
struct fcoe_softc *fc;

fc = container_of(ptype, struct fcoe_softc, fip_packet_type);
fcoe_ctlr_recv(&fc->ctlr, skb);
return 0;
}

/**
* fcoe_fip_send() - send an Ethernet-encapsulated FIP frame.
* @fip: FCoE controller.
* @skb: FIP Packet.
*/
static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
{
skb->dev = fcoe_from_ctlr(fip)->real_dev;
dev_queue_xmit(skb);
}

/**
* fcoe_update_src_mac() - Update Ethernet MAC filters.
* @fip: FCoE controller.
* @old: Unicast MAC address to delete if the MAC is non-zero.
* @new: Unicast MAC address to add.
*
* Remove any previously-set unicast MAC filter.
* Add secondary FCoE MAC address filter for our OUI.
*/
static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new)
{
struct fcoe_softc *fc;

fc = fcoe_from_ctlr(fip);
rtnl_lock();
if (!is_zero_ether_addr(old))
dev_unicast_delete(fc->real_dev, old, ETH_ALEN);
dev_unicast_add(fc->real_dev, new, ETH_ALEN);
rtnl_unlock();
}

/**
* fcoe_lport_config() - sets up the fc_lport
* @lp: ptr to the fc_lport
Expand Down Expand Up @@ -167,6 +219,29 @@ static int fcoe_lport_config(struct fc_lport *lp)
return 0;
}

/**
* fcoe_netdev_cleanup() - clean up netdev configurations
* @fc: ptr to the fcoe_softc
*/
void fcoe_netdev_cleanup(struct fcoe_softc *fc)
{
u8 flogi_maddr[ETH_ALEN];

/* Don't listen for Ethernet packets anymore */
dev_remove_pack(&fc->fcoe_packet_type);
dev_remove_pack(&fc->fip_packet_type);

/* Delete secondary MAC addresses */
rtnl_lock();
memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
dev_unicast_delete(fc->real_dev, flogi_maddr, ETH_ALEN);
if (!is_zero_ether_addr(fc->ctlr.data_src_addr))
dev_unicast_delete(fc->real_dev,
fc->ctlr.data_src_addr, ETH_ALEN);
dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
rtnl_unlock();
}

/**
* fcoe_netdev_config() - Set up netdev for SW FCoE
* @lp : ptr to the fc_lport
Expand Down Expand Up @@ -267,6 +342,11 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
fc->fcoe_packet_type.dev = fc->real_dev;
dev_add_pack(&fc->fcoe_packet_type);

fc->fip_packet_type.func = fcoe_fip_recv;
fc->fip_packet_type.type = htons(ETH_P_FIP);
fc->fip_packet_type.dev = fc->real_dev;
dev_add_pack(&fc->fip_packet_type);

return 0;
}

Expand Down Expand Up @@ -334,7 +414,6 @@ static int fcoe_if_destroy(struct net_device *netdev)
{
struct fc_lport *lp = NULL;
struct fcoe_softc *fc;
u8 flogi_maddr[ETH_ALEN];

BUG_ON(!netdev);

Expand All @@ -353,9 +432,10 @@ static int fcoe_if_destroy(struct net_device *netdev)
/* Remove the instance from fcoe's list */
fcoe_hostlist_remove(lp);

/* Don't listen for Ethernet packets anymore */
dev_remove_pack(&fc->fcoe_packet_type);
dev_remove_pack(&fc->fip_packet_type);
/* clean up netdev configurations */
fcoe_netdev_cleanup(fc);

/* tear-down the FCoE controller */
fcoe_ctlr_destroy(&fc->ctlr);

/* Cleanup the fc_lport */
Expand All @@ -370,16 +450,6 @@ static int fcoe_if_destroy(struct net_device *netdev)
if (lp->emp)
fc_exch_mgr_free(lp->emp);

/* Delete secondary MAC addresses */
rtnl_lock();
memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
dev_unicast_delete(fc->real_dev, flogi_maddr, ETH_ALEN);
if (!is_zero_ether_addr(fc->ctlr.data_src_addr))
dev_unicast_delete(fc->real_dev,
fc->ctlr.data_src_addr, ETH_ALEN);
dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
rtnl_unlock();

/* Free the per-CPU revieve threads */
fcoe_percpu_clean(lp);

Expand Down Expand Up @@ -438,58 +508,6 @@ static struct libfc_function_template fcoe_libfc_fcn_templ = {
.ddp_done = fcoe_ddp_done,
};

/**
* fcoe_fip_recv - handle a received FIP frame.
* @skb: the receive skb
* @dev: associated &net_device
* @ptype: the &packet_type structure which was used to register this handler.
* @orig_dev: original receive &net_device, in case @dev is a bond.
*
* Returns: 0 for success
*/
static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype,
struct net_device *orig_dev)
{
struct fcoe_softc *fc;

fc = container_of(ptype, struct fcoe_softc, fip_packet_type);
fcoe_ctlr_recv(&fc->ctlr, skb);
return 0;
}

/**
* fcoe_fip_send() - send an Ethernet-encapsulated FIP frame.
* @fip: FCoE controller.
* @skb: FIP Packet.
*/
static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
{
skb->dev = fcoe_from_ctlr(fip)->real_dev;
dev_queue_xmit(skb);
}

/**
* fcoe_update_src_mac() - Update Ethernet MAC filters.
* @fip: FCoE controller.
* @old: Unicast MAC address to delete if the MAC is non-zero.
* @new: Unicast MAC address to add.
*
* Remove any previously-set unicast MAC filter.
* Add secondary FCoE MAC address filter for our OUI.
*/
static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new)
{
struct fcoe_softc *fc;

fc = fcoe_from_ctlr(fip);
rtnl_lock();
if (!is_zero_ether_addr(old))
dev_unicast_delete(fc->real_dev, old, ETH_ALEN);
dev_unicast_add(fc->real_dev, new, ETH_ALEN);
rtnl_unlock();
}

/**
* fcoe_if_create() - this function creates the fcoe interface
* @netdev: pointer the associated netdevice
Expand Down Expand Up @@ -531,37 +549,32 @@ static int fcoe_if_create(struct net_device *netdev)
goto out_host_put;
}

/* configure lport network properties */
rc = fcoe_netdev_config(lp, netdev);
if (rc) {
FC_DBG("Could not configure netdev for lport\n");
goto out_host_put;
}

/*
* Initialize FIP.
*/
fcoe_ctlr_init(&fc->ctlr);
fc->ctlr.send = fcoe_fip_send;
fc->ctlr.update_mac = fcoe_update_src_mac;

fc->fip_packet_type.func = fcoe_fip_recv;
fc->fip_packet_type.type = htons(ETH_P_FIP);
fc->fip_packet_type.dev = fc->real_dev;
dev_add_pack(&fc->fip_packet_type);
/* configure lport network properties */
rc = fcoe_netdev_config(lp, netdev);
if (rc) {
FC_DBG("Could not configure netdev for the interface\n");
goto out_netdev_cleanup;
}

/* configure lport scsi host properties */
rc = fcoe_shost_config(lp, shost, &netdev->dev);
if (rc) {
FC_DBG("Could not configure shost for lport\n");
goto out_host_put;
goto out_netdev_cleanup;
}

/* lport exch manager allocation */
rc = fcoe_em_config(lp);
if (rc) {
FC_DBG("Could not configure em for lport\n");
goto out_host_put;
goto out_netdev_cleanup;
}

/* Initialize the library */
Expand All @@ -587,6 +600,8 @@ static int fcoe_if_create(struct net_device *netdev)

out_lp_destroy:
fc_exch_mgr_free(lp->emp); /* Free the EM */
out_netdev_cleanup:
fcoe_netdev_cleanup(fc);
out_host_put:
scsi_host_put(lp->host);
return rc;
Expand Down

0 comments on commit 33f6ed0

Please sign in to comment.