Skip to content

Commit

Permalink
be2net: refactor VF setup/teardown code into be_vf_setup/clear()
Browse files Browse the repository at this point in the history
Currently the code for VF setup/teardown done by a PF (if_create,
mac_add_config, link_status_query etc) is scattered; this patch
refactors this code into be_vf_setup() and be_vf_clear().  The
if_create/if_destroy/mac_addr_query cmds are now called after the MCCQ
is created; so these cmds are now modified to use the MCCQ instead of
MBOX.

Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sathya Perla authored and David S. Miller committed Oct 24, 2011
1 parent a54769f commit f9449ab
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 152 deletions.
66 changes: 40 additions & 26 deletions drivers/net/ethernet/emulex/benet/be_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,18 +615,21 @@ int be_cmd_eq_create(struct be_adapter *adapter,
return status;
}

/* Uses mbox */
/* Use MCC */
int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
u8 type, bool permanent, u32 if_handle)
{
struct be_mcc_wrb *wrb;
struct be_cmd_req_mac_query *req;
int status;

if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1;
spin_lock_bh(&adapter->mcc_lock);

wrb = wrb_from_mbox(adapter);
wrb = wrb_from_mccq(adapter);
if (!wrb) {
status = -EBUSY;
goto err;
}
req = embedded_payload(wrb);

be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0,
Expand All @@ -643,13 +646,14 @@ int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
req->permanent = 0;
}

status = be_mbox_notify_wait(adapter);
status = be_mcc_notify_wait(adapter);
if (!status) {
struct be_cmd_resp_mac_query *resp = embedded_payload(wrb);
memcpy(mac_addr, resp->mac.addr, ETH_ALEN);
}

mutex_unlock(&adapter->mbox_lock);
err:
spin_unlock_bh(&adapter->mcc_lock);
return status;
}

Expand Down Expand Up @@ -1111,20 +1115,22 @@ int be_cmd_rxq_destroy(struct be_adapter *adapter, struct be_queue_info *q)
}

/* Create an rx filtering policy configuration on an i/f
* Uses mbox
* Uses MCCQ
*/
int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
u8 *mac, bool pmac_invalid, u32 *if_handle, u32 *pmac_id,
u32 domain)
u8 *mac, u32 *if_handle, u32 *pmac_id, u32 domain)
{
struct be_mcc_wrb *wrb;
struct be_cmd_req_if_create *req;
int status;

if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1;
spin_lock_bh(&adapter->mcc_lock);

wrb = wrb_from_mbox(adapter);
wrb = wrb_from_mccq(adapter);
if (!wrb) {
status = -EBUSY;
goto err;
}
req = embedded_payload(wrb);

be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0,
Expand All @@ -1136,23 +1142,25 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
req->hdr.domain = domain;
req->capability_flags = cpu_to_le32(cap_flags);
req->enable_flags = cpu_to_le32(en_flags);
req->pmac_invalid = pmac_invalid;
if (!pmac_invalid)
if (mac)
memcpy(req->mac_addr, mac, ETH_ALEN);
else
req->pmac_invalid = true;

status = be_mbox_notify_wait(adapter);
status = be_mcc_notify_wait(adapter);
if (!status) {
struct be_cmd_resp_if_create *resp = embedded_payload(wrb);
*if_handle = le32_to_cpu(resp->interface_id);
if (!pmac_invalid)
if (mac)
*pmac_id = le32_to_cpu(resp->pmac_id);
}

mutex_unlock(&adapter->mbox_lock);
err:
spin_unlock_bh(&adapter->mcc_lock);
return status;
}

/* Uses mbox */
/* Uses MCCQ */
int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain)
{
struct be_mcc_wrb *wrb;
Expand All @@ -1162,10 +1170,16 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain)
if (adapter->eeh_err)
return -EIO;

if (mutex_lock_interruptible(&adapter->mbox_lock))
return -1;
if (!interface_id)
return 0;

wrb = wrb_from_mbox(adapter);
spin_lock_bh(&adapter->mcc_lock);

wrb = wrb_from_mccq(adapter);
if (!wrb) {
status = -EBUSY;
goto err;
}
req = embedded_payload(wrb);

be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0,
Expand All @@ -1177,10 +1191,9 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id, u32 domain)
req->hdr.domain = domain;
req->interface_id = cpu_to_le32(interface_id);

status = be_mbox_notify_wait(adapter);

mutex_unlock(&adapter->mbox_lock);

status = be_mcc_notify_wait(adapter);
err:
spin_unlock_bh(&adapter->mcc_lock);
return status;
}

Expand Down Expand Up @@ -1301,7 +1314,8 @@ int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed,
struct be_cmd_resp_link_status *resp = embedded_payload(wrb);
if (resp->mac_speed != PHY_LINK_SPEED_ZERO) {
*link_speed = le16_to_cpu(resp->link_speed);
*mac_speed = resp->mac_speed;
if (mac_speed)
*mac_speed = resp->mac_speed;
}
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/emulex/benet/be_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -1413,8 +1413,8 @@ extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id,
u32 pmac_id, u32 domain);
extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags,
u32 en_flags, u8 *mac, bool pmac_invalid,
u32 *if_handle, u32 *pmac_id, u32 domain);
u32 en_flags, u8 *mac, u32 *if_handle, u32 *pmac_id,
u32 domain);
extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle,
u32 domain);
extern int be_cmd_eq_create(struct be_adapter *adapter,
Expand Down
Loading

0 comments on commit f9449ab

Please sign in to comment.