aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorPadmanabh Ratnakar <padmanabh.ratnakar@emulex.com>2012-02-03 04:50:17 -0500
committerDavid S. Miller <davem@davemloft.net>2012-02-04 16:06:28 -0500
commite5e1ee89461543043a0144e6dac90547fefe2f89 (patch)
tree2ab21d27458dc97c1e1b096ede58ba5569e844a3 /drivers/net
parent57cd80d4d511748f3973accc6919e7e1e1936ebb (diff)
be2net: Use new implementation of get mac list command
VFs use get mac list command to get their mac address. The format of this command has changed. Update driver to use the new format. Signed-off-by: Mammatha Edhala <mammatha.edhala@emulex.com> Signed-off-by: Padmanabh Ratnakar <padmanabh.ratnakar@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c67
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h36
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c29
3 files changed, 92 insertions, 40 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index dd6e8e2b3476..29dff7de66b6 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2300,52 +2300,81 @@ err:
2300 2300
2301/* Uses synchronous MCCQ */ 2301/* Uses synchronous MCCQ */
2302int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, 2302int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
2303 u32 *pmac_id) 2303 bool *pmac_id_active, u32 *pmac_id, u8 *mac)
2304{ 2304{
2305 struct be_mcc_wrb *wrb; 2305 struct be_mcc_wrb *wrb;
2306 struct be_cmd_req_get_mac_list *req; 2306 struct be_cmd_req_get_mac_list *req;
2307 int status; 2307 int status;
2308 int mac_count; 2308 int mac_count;
2309 struct be_dma_mem get_mac_list_cmd;
2310 int i;
2311
2312 memset(&get_mac_list_cmd, 0, sizeof(struct be_dma_mem));
2313 get_mac_list_cmd.size = sizeof(struct be_cmd_resp_get_mac_list);
2314 get_mac_list_cmd.va = pci_alloc_consistent(adapter->pdev,
2315 get_mac_list_cmd.size,
2316 &get_mac_list_cmd.dma);
2317
2318 if (!get_mac_list_cmd.va) {
2319 dev_err(&adapter->pdev->dev,
2320 "Memory allocation failure during GET_MAC_LIST\n");
2321 return -ENOMEM;
2322 }
2309 2323
2310 spin_lock_bh(&adapter->mcc_lock); 2324 spin_lock_bh(&adapter->mcc_lock);
2311 2325
2312 wrb = wrb_from_mccq(adapter); 2326 wrb = wrb_from_mccq(adapter);
2313 if (!wrb) { 2327 if (!wrb) {
2314 status = -EBUSY; 2328 status = -EBUSY;
2315 goto err; 2329 goto out;
2316 } 2330 }
2317 req = embedded_payload(wrb); 2331
2332 req = get_mac_list_cmd.va;
2318 2333
2319 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 2334 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
2320 OPCODE_COMMON_GET_MAC_LIST, sizeof(*req), 2335 OPCODE_COMMON_GET_MAC_LIST, sizeof(*req),
2321 wrb, NULL); 2336 wrb, &get_mac_list_cmd);
2322 2337
2323 req->hdr.domain = domain; 2338 req->hdr.domain = domain;
2339 req->mac_type = MAC_ADDRESS_TYPE_NETWORK;
2340 req->perm_override = 1;
2324 2341
2325 status = be_mcc_notify_wait(adapter); 2342 status = be_mcc_notify_wait(adapter);
2326 if (!status) { 2343 if (!status) {
2327 struct be_cmd_resp_get_mac_list *resp = 2344 struct be_cmd_resp_get_mac_list *resp =
2328 embedded_payload(wrb); 2345 get_mac_list_cmd.va;
2329 int i; 2346 mac_count = resp->true_mac_count + resp->pseudo_mac_count;
2330 u8 *ctxt = &resp->context[0][0]; 2347 /* Mac list returned could contain one or more active mac_ids
2331 status = -EIO; 2348 * or one or more pseudo permanant mac addresses. If an active
2332 mac_count = resp->mac_count; 2349 * mac_id is present, return first active mac_id found
2333 be_dws_le_to_cpu(&resp->context, sizeof(resp->context)); 2350 */
2334 for (i = 0; i < mac_count; i++) { 2351 for (i = 0; i < mac_count; i++) {
2335 if (!AMAP_GET_BITS(struct amap_get_mac_list_context, 2352 struct get_list_macaddr *mac_entry;
2336 act, ctxt)) { 2353 u16 mac_addr_size;
2337 *pmac_id = AMAP_GET_BITS 2354 u32 mac_id;
2338 (struct amap_get_mac_list_context, 2355
2339 macid, ctxt); 2356 mac_entry = &resp->macaddr_list[i];
2340 status = 0; 2357 mac_addr_size = le16_to_cpu(mac_entry->mac_addr_size);
2341 break; 2358 /* mac_id is a 32 bit value and mac_addr size
2359 * is 6 bytes
2360 */
2361 if (mac_addr_size == sizeof(u32)) {
2362 *pmac_id_active = true;
2363 mac_id = mac_entry->mac_addr_id.s_mac_id.mac_id;
2364 *pmac_id = le32_to_cpu(mac_id);
2365 goto out;
2342 } 2366 }
2343 ctxt += sizeof(struct amap_get_mac_list_context) / 8;
2344 } 2367 }
2368 /* If no active mac_id found, return first pseudo mac addr */
2369 *pmac_id_active = false;
2370 memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr,
2371 ETH_ALEN);
2345 } 2372 }
2346 2373
2347err: 2374out:
2348 spin_unlock_bh(&adapter->mcc_lock); 2375 spin_unlock_bh(&adapter->mcc_lock);
2376 pci_free_consistent(adapter->pdev, get_mac_list_cmd.size,
2377 get_mac_list_cmd.va, get_mac_list_cmd.dma);
2349 return status; 2378 return status;
2350} 2379}
2351 2380
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index bbd012b41fb4..5bb66c80f05e 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1346,22 +1346,36 @@ struct be_cmd_resp_set_func_cap {
1346 1346
1347/******************** GET/SET_MACLIST **************************/ 1347/******************** GET/SET_MACLIST **************************/
1348#define BE_MAX_MAC 64 1348#define BE_MAX_MAC 64
1349struct amap_get_mac_list_context {
1350 u8 macid[31];
1351 u8 act;
1352} __packed;
1353
1354struct be_cmd_req_get_mac_list { 1349struct be_cmd_req_get_mac_list {
1355 struct be_cmd_req_hdr hdr; 1350 struct be_cmd_req_hdr hdr;
1356 u32 rsvd; 1351 u8 mac_type;
1352 u8 perm_override;
1353 u16 iface_id;
1354 u32 mac_id;
1355 u32 rsvd[3];
1356} __packed;
1357
1358struct get_list_macaddr {
1359 u16 mac_addr_size;
1360 union {
1361 u8 macaddr[6];
1362 struct {
1363 u8 rsvd[2];
1364 u32 mac_id;
1365 } __packed s_mac_id;
1366 } __packed mac_addr_id;
1357} __packed; 1367} __packed;
1358 1368
1359struct be_cmd_resp_get_mac_list { 1369struct be_cmd_resp_get_mac_list {
1360 struct be_cmd_resp_hdr hdr; 1370 struct be_cmd_resp_hdr hdr;
1361 u8 mac_count; 1371 struct get_list_macaddr fd_macaddr; /* Factory default mac */
1362 u8 rsvd1; 1372 struct get_list_macaddr macid_macaddr; /* soft mac */
1363 u16 rsvd2; 1373 u8 true_mac_count;
1364 u8 context[sizeof(struct amap_get_mac_list_context) / 8][BE_MAX_MAC]; 1374 u8 pseudo_mac_count;
1375 u8 mac_list_size;
1376 u8 rsvd;
1377 /* perm override mac */
1378 struct get_list_macaddr macaddr_list[BE_MAX_MAC];
1365} __packed; 1379} __packed;
1366 1380
1367struct be_cmd_req_set_mac_list { 1381struct be_cmd_req_set_mac_list {
@@ -1575,7 +1589,7 @@ extern int be_cmd_req_native_mode(struct be_adapter *adapter);
1575extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size); 1589extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size);
1576extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf); 1590extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf);
1577extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, 1591extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
1578 u32 *pmac_id); 1592 bool *pmac_id_active, u32 *pmac_id, u8 *mac);
1579extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, 1593extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array,
1580 u8 mac_count, u32 domain); 1594 u8 mac_count, u32 domain);
1581 1595
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 1395f803cf7f..780498784d8e 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2608,19 +2608,28 @@ static void be_setup_init(struct be_adapter *adapter)
2608 adapter->eq_next_idx = 0; 2608 adapter->eq_next_idx = 0;
2609} 2609}
2610 2610
2611static int be_configure_mac_from_list(struct be_adapter *adapter, u8 *mac) 2611static int be_add_mac_from_list(struct be_adapter *adapter, u8 *mac)
2612{ 2612{
2613 u32 pmac_id; 2613 u32 pmac_id;
2614 int status = be_cmd_get_mac_from_list(adapter, 0, &pmac_id); 2614 int status;
2615 if (status != 0) 2615 bool pmac_id_active;
2616 goto do_none; 2616
2617 status = be_cmd_mac_addr_query(adapter, mac, 2617 status = be_cmd_get_mac_from_list(adapter, 0, &pmac_id_active,
2618 MAC_ADDRESS_TYPE_NETWORK, 2618 &pmac_id, mac);
2619 false, adapter->if_handle, pmac_id);
2620 if (status != 0) 2619 if (status != 0)
2621 goto do_none; 2620 goto do_none;
2622 status = be_cmd_pmac_add(adapter, mac, adapter->if_handle, 2621
2623 &adapter->pmac_id, 0); 2622 if (pmac_id_active) {
2623 status = be_cmd_mac_addr_query(adapter, mac,
2624 MAC_ADDRESS_TYPE_NETWORK,
2625 false, adapter->if_handle, pmac_id);
2626
2627 if (!status)
2628 adapter->pmac_id = pmac_id;
2629 } else {
2630 status = be_cmd_pmac_add(adapter, mac,
2631 adapter->if_handle, &adapter->pmac_id, 0);
2632 }
2624do_none: 2633do_none:
2625 return status; 2634 return status;
2626} 2635}
@@ -2685,7 +2694,7 @@ static int be_setup(struct be_adapter *adapter)
2685 */ 2694 */
2686 if (!be_physfn(adapter)) { 2695 if (!be_physfn(adapter)) {
2687 if (lancer_chip(adapter)) 2696 if (lancer_chip(adapter))
2688 status = be_configure_mac_from_list(adapter, mac); 2697 status = be_add_mac_from_list(adapter, mac);
2689 else 2698 else
2690 status = be_cmd_mac_addr_query(adapter, mac, 2699 status = be_cmd_mac_addr_query(adapter, mac,
2691 MAC_ADDRESS_TYPE_NETWORK, false, 2700 MAC_ADDRESS_TYPE_NETWORK, false,