diff options
Diffstat (limited to 'drivers/net/benet')
-rw-r--r-- | drivers/net/benet/be.h | 11 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.c | 14 | ||||
-rw-r--r-- | drivers/net/benet/be_cmds.h | 2 | ||||
-rw-r--r-- | drivers/net/benet/be_ethtool.c | 5 | ||||
-rw-r--r-- | drivers/net/benet/be_hw.h | 3 | ||||
-rw-r--r-- | drivers/net/benet/be_main.c | 315 |
6 files changed, 253 insertions, 97 deletions
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h index 56387b191c96..373c1a563474 100644 --- a/drivers/net/benet/be.h +++ b/drivers/net/benet/be.h | |||
@@ -84,6 +84,8 @@ static inline char *nic_name(struct pci_dev *pdev) | |||
84 | 84 | ||
85 | #define FW_VER_LEN 32 | 85 | #define FW_VER_LEN 32 |
86 | 86 | ||
87 | #define BE_MAX_VF 32 | ||
88 | |||
87 | struct be_dma_mem { | 89 | struct be_dma_mem { |
88 | void *va; | 90 | void *va; |
89 | dma_addr_t dma; | 91 | dma_addr_t dma; |
@@ -207,7 +209,7 @@ struct be_tx_obj { | |||
207 | /* Struct to remember the pages posted for rx frags */ | 209 | /* Struct to remember the pages posted for rx frags */ |
208 | struct be_rx_page_info { | 210 | struct be_rx_page_info { |
209 | struct page *page; | 211 | struct page *page; |
210 | dma_addr_t bus; | 212 | DEFINE_DMA_UNMAP_ADDR(bus); |
211 | u16 page_offset; | 213 | u16 page_offset; |
212 | bool last_page_user; | 214 | bool last_page_user; |
213 | }; | 215 | }; |
@@ -281,8 +283,15 @@ struct be_adapter { | |||
281 | u8 port_type; | 283 | u8 port_type; |
282 | u8 transceiver; | 284 | u8 transceiver; |
283 | u8 generation; /* BladeEngine ASIC generation */ | 285 | u8 generation; /* BladeEngine ASIC generation */ |
286 | |||
287 | bool sriov_enabled; | ||
288 | u32 vf_if_handle[BE_MAX_VF]; | ||
289 | u32 vf_pmac_id[BE_MAX_VF]; | ||
290 | u8 base_eq_id; | ||
284 | }; | 291 | }; |
285 | 292 | ||
293 | #define be_physfn(adapter) (!adapter->pdev->is_virtfn) | ||
294 | |||
286 | /* BladeEngine Generation numbers */ | 295 | /* BladeEngine Generation numbers */ |
287 | #define BE_GEN2 2 | 296 | #define BE_GEN2 2 |
288 | #define BE_GEN3 3 | 297 | #define BE_GEN3 3 |
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index d0ef4ac987cd..e79bf8b9af3b 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -843,7 +843,8 @@ int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, | |||
843 | * Uses mbox | 843 | * Uses mbox |
844 | */ | 844 | */ |
845 | int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, | 845 | int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, |
846 | u8 *mac, bool pmac_invalid, u32 *if_handle, u32 *pmac_id) | 846 | u8 *mac, bool pmac_invalid, u32 *if_handle, u32 *pmac_id, |
847 | u32 domain) | ||
847 | { | 848 | { |
848 | struct be_mcc_wrb *wrb; | 849 | struct be_mcc_wrb *wrb; |
849 | struct be_cmd_req_if_create *req; | 850 | struct be_cmd_req_if_create *req; |
@@ -860,6 +861,7 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, | |||
860 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 861 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
861 | OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req)); | 862 | OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req)); |
862 | 863 | ||
864 | req->hdr.domain = domain; | ||
863 | req->capability_flags = cpu_to_le32(cap_flags); | 865 | req->capability_flags = cpu_to_le32(cap_flags); |
864 | req->enable_flags = cpu_to_le32(en_flags); | 866 | req->enable_flags = cpu_to_le32(en_flags); |
865 | req->pmac_invalid = pmac_invalid; | 867 | req->pmac_invalid = pmac_invalid; |
@@ -1111,6 +1113,10 @@ int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en) | |||
1111 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, | 1113 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
1112 | OPCODE_ETH_PROMISCUOUS, sizeof(*req)); | 1114 | OPCODE_ETH_PROMISCUOUS, sizeof(*req)); |
1113 | 1115 | ||
1116 | /* In FW versions X.102.149/X.101.487 and later, | ||
1117 | * the port setting associated only with the | ||
1118 | * issuing pci function will take effect | ||
1119 | */ | ||
1114 | if (port_num) | 1120 | if (port_num) |
1115 | req->port1_promiscuous = en; | 1121 | req->port1_promiscuous = en; |
1116 | else | 1122 | else |
@@ -1157,13 +1163,13 @@ int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id, | |||
1157 | req->interface_id = if_id; | 1163 | req->interface_id = if_id; |
1158 | if (netdev) { | 1164 | if (netdev) { |
1159 | int i; | 1165 | int i; |
1160 | struct dev_mc_list *mc; | 1166 | struct netdev_hw_addr *ha; |
1161 | 1167 | ||
1162 | req->num_mac = cpu_to_le16(netdev_mc_count(netdev)); | 1168 | req->num_mac = cpu_to_le16(netdev_mc_count(netdev)); |
1163 | 1169 | ||
1164 | i = 0; | 1170 | i = 0; |
1165 | netdev_for_each_mc_addr(mc, netdev) | 1171 | netdev_for_each_mc_addr(ha, netdev) |
1166 | memcpy(req->mac[i].byte, mc->dmi_addr, ETH_ALEN); | 1172 | memcpy(req->mac[i].byte, ha->addr, ETH_ALEN); |
1167 | } else { | 1173 | } else { |
1168 | req->promiscuous = 1; | 1174 | req->promiscuous = 1; |
1169 | } | 1175 | } |
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h index cce61f9a3714..763dc199e337 100644 --- a/drivers/net/benet/be_cmds.h +++ b/drivers/net/benet/be_cmds.h | |||
@@ -878,7 +878,7 @@ extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, | |||
878 | extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id); | 878 | extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id); |
879 | extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, | 879 | extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, |
880 | u32 en_flags, u8 *mac, bool pmac_invalid, | 880 | u32 en_flags, u8 *mac, bool pmac_invalid, |
881 | u32 *if_handle, u32 *pmac_id); | 881 | u32 *if_handle, u32 *pmac_id, u32 domain); |
882 | extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle); | 882 | extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle); |
883 | extern int be_cmd_eq_create(struct be_adapter *adapter, | 883 | extern int be_cmd_eq_create(struct be_adapter *adapter, |
884 | struct be_queue_info *eq, int eq_delay); | 884 | struct be_queue_info *eq, int eq_delay); |
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c index 51e1065e7897..200e98515909 100644 --- a/drivers/net/benet/be_ethtool.c +++ b/drivers/net/benet/be_ethtool.c | |||
@@ -276,8 +276,6 @@ be_get_ethtool_stats(struct net_device *netdev, | |||
276 | data[i] = (et_stats[i].size == sizeof(u64)) ? | 276 | data[i] = (et_stats[i].size == sizeof(u64)) ? |
277 | *(u64 *)p: *(u32 *)p; | 277 | *(u64 *)p: *(u32 *)p; |
278 | } | 278 | } |
279 | |||
280 | return; | ||
281 | } | 279 | } |
282 | 280 | ||
283 | static void | 281 | static void |
@@ -466,7 +464,6 @@ be_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | |||
466 | else | 464 | else |
467 | wol->wolopts = 0; | 465 | wol->wolopts = 0; |
468 | memset(&wol->sopass, 0, sizeof(wol->sopass)); | 466 | memset(&wol->sopass, 0, sizeof(wol->sopass)); |
469 | return; | ||
470 | } | 467 | } |
471 | 468 | ||
472 | static int | 469 | static int |
@@ -496,7 +493,7 @@ be_test_ddr_dma(struct be_adapter *adapter) | |||
496 | ddrdma_cmd.va = pci_alloc_consistent(adapter->pdev, ddrdma_cmd.size, | 493 | ddrdma_cmd.va = pci_alloc_consistent(adapter->pdev, ddrdma_cmd.size, |
497 | &ddrdma_cmd.dma); | 494 | &ddrdma_cmd.dma); |
498 | if (!ddrdma_cmd.va) { | 495 | if (!ddrdma_cmd.va) { |
499 | dev_err(&adapter->pdev->dev, "Memory allocation failure \n"); | 496 | dev_err(&adapter->pdev->dev, "Memory allocation failure\n"); |
500 | return -ENOMEM; | 497 | return -ENOMEM; |
501 | } | 498 | } |
502 | 499 | ||
diff --git a/drivers/net/benet/be_hw.h b/drivers/net/benet/be_hw.h index 2d4a4b827637..063026de4957 100644 --- a/drivers/net/benet/be_hw.h +++ b/drivers/net/benet/be_hw.h | |||
@@ -99,6 +99,9 @@ | |||
99 | /* Number of entries posted */ | 99 | /* Number of entries posted */ |
100 | #define DB_MCCQ_NUM_POSTED_SHIFT (16) /* bits 16 - 29 */ | 100 | #define DB_MCCQ_NUM_POSTED_SHIFT (16) /* bits 16 - 29 */ |
101 | 101 | ||
102 | /********** SRIOV VF PCICFG OFFSET ********/ | ||
103 | #define SRIOV_VF_PCICFG_OFFSET (4096) | ||
104 | |||
102 | /* Flashrom related descriptors */ | 105 | /* Flashrom related descriptors */ |
103 | #define IMAGE_TYPE_FIRMWARE 160 | 106 | #define IMAGE_TYPE_FIRMWARE 160 |
104 | #define IMAGE_TYPE_BOOTCODE 224 | 107 | #define IMAGE_TYPE_BOOTCODE 224 |
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index ec6ace802256..058d7f95f5ae 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -26,8 +26,11 @@ MODULE_AUTHOR("ServerEngines Corporation"); | |||
26 | MODULE_LICENSE("GPL"); | 26 | MODULE_LICENSE("GPL"); |
27 | 27 | ||
28 | static unsigned int rx_frag_size = 2048; | 28 | static unsigned int rx_frag_size = 2048; |
29 | static unsigned int num_vfs; | ||
29 | module_param(rx_frag_size, uint, S_IRUGO); | 30 | module_param(rx_frag_size, uint, S_IRUGO); |
31 | module_param(num_vfs, uint, S_IRUGO); | ||
30 | MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data."); | 32 | MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data."); |
33 | MODULE_PARM_DESC(num_vfs, "Number of PCI VFs to initialize"); | ||
31 | 34 | ||
32 | static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = { | 35 | static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = { |
33 | { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, | 36 | { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, |
@@ -138,12 +141,19 @@ static int be_mac_addr_set(struct net_device *netdev, void *p) | |||
138 | if (!is_valid_ether_addr(addr->sa_data)) | 141 | if (!is_valid_ether_addr(addr->sa_data)) |
139 | return -EADDRNOTAVAIL; | 142 | return -EADDRNOTAVAIL; |
140 | 143 | ||
144 | /* MAC addr configuration will be done in hardware for VFs | ||
145 | * by their corresponding PFs. Just copy to netdev addr here | ||
146 | */ | ||
147 | if (!be_physfn(adapter)) | ||
148 | goto netdev_addr; | ||
149 | |||
141 | status = be_cmd_pmac_del(adapter, adapter->if_handle, adapter->pmac_id); | 150 | status = be_cmd_pmac_del(adapter, adapter->if_handle, adapter->pmac_id); |
142 | if (status) | 151 | if (status) |
143 | return status; | 152 | return status; |
144 | 153 | ||
145 | status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data, | 154 | status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data, |
146 | adapter->if_handle, &adapter->pmac_id); | 155 | adapter->if_handle, &adapter->pmac_id); |
156 | netdev_addr: | ||
147 | if (!status) | 157 | if (!status) |
148 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); | 158 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); |
149 | 159 | ||
@@ -386,26 +396,48 @@ static void wrb_fill_hdr(struct be_eth_hdr_wrb *hdr, struct sk_buff *skb, | |||
386 | AMAP_SET_BITS(struct amap_eth_hdr_wrb, len, hdr, len); | 396 | AMAP_SET_BITS(struct amap_eth_hdr_wrb, len, hdr, len); |
387 | } | 397 | } |
388 | 398 | ||
399 | static void unmap_tx_frag(struct pci_dev *pdev, struct be_eth_wrb *wrb, | ||
400 | bool unmap_single) | ||
401 | { | ||
402 | dma_addr_t dma; | ||
403 | |||
404 | be_dws_le_to_cpu(wrb, sizeof(*wrb)); | ||
405 | |||
406 | dma = (u64)wrb->frag_pa_hi << 32 | (u64)wrb->frag_pa_lo; | ||
407 | if (wrb->frag_len) { | ||
408 | if (unmap_single) | ||
409 | pci_unmap_single(pdev, dma, wrb->frag_len, | ||
410 | PCI_DMA_TODEVICE); | ||
411 | else | ||
412 | pci_unmap_page(pdev, dma, wrb->frag_len, | ||
413 | PCI_DMA_TODEVICE); | ||
414 | } | ||
415 | } | ||
389 | 416 | ||
390 | static int make_tx_wrbs(struct be_adapter *adapter, | 417 | static int make_tx_wrbs(struct be_adapter *adapter, |
391 | struct sk_buff *skb, u32 wrb_cnt, bool dummy_wrb) | 418 | struct sk_buff *skb, u32 wrb_cnt, bool dummy_wrb) |
392 | { | 419 | { |
393 | u64 busaddr; | 420 | dma_addr_t busaddr; |
394 | u32 i, copied = 0; | 421 | int i, copied = 0; |
395 | struct pci_dev *pdev = adapter->pdev; | 422 | struct pci_dev *pdev = adapter->pdev; |
396 | struct sk_buff *first_skb = skb; | 423 | struct sk_buff *first_skb = skb; |
397 | struct be_queue_info *txq = &adapter->tx_obj.q; | 424 | struct be_queue_info *txq = &adapter->tx_obj.q; |
398 | struct be_eth_wrb *wrb; | 425 | struct be_eth_wrb *wrb; |
399 | struct be_eth_hdr_wrb *hdr; | 426 | struct be_eth_hdr_wrb *hdr; |
427 | bool map_single = false; | ||
428 | u16 map_head; | ||
400 | 429 | ||
401 | hdr = queue_head_node(txq); | 430 | hdr = queue_head_node(txq); |
402 | atomic_add(wrb_cnt, &txq->used); | ||
403 | queue_head_inc(txq); | 431 | queue_head_inc(txq); |
432 | map_head = txq->head; | ||
404 | 433 | ||
405 | if (skb->len > skb->data_len) { | 434 | if (skb->len > skb->data_len) { |
406 | int len = skb->len - skb->data_len; | 435 | int len = skb_headlen(skb); |
407 | busaddr = pci_map_single(pdev, skb->data, len, | 436 | busaddr = pci_map_single(pdev, skb->data, len, |
408 | PCI_DMA_TODEVICE); | 437 | PCI_DMA_TODEVICE); |
438 | if (pci_dma_mapping_error(pdev, busaddr)) | ||
439 | goto dma_err; | ||
440 | map_single = true; | ||
409 | wrb = queue_head_node(txq); | 441 | wrb = queue_head_node(txq); |
410 | wrb_fill(wrb, busaddr, len); | 442 | wrb_fill(wrb, busaddr, len); |
411 | be_dws_cpu_to_le(wrb, sizeof(*wrb)); | 443 | be_dws_cpu_to_le(wrb, sizeof(*wrb)); |
@@ -419,6 +451,8 @@ static int make_tx_wrbs(struct be_adapter *adapter, | |||
419 | busaddr = pci_map_page(pdev, frag->page, | 451 | busaddr = pci_map_page(pdev, frag->page, |
420 | frag->page_offset, | 452 | frag->page_offset, |
421 | frag->size, PCI_DMA_TODEVICE); | 453 | frag->size, PCI_DMA_TODEVICE); |
454 | if (pci_dma_mapping_error(pdev, busaddr)) | ||
455 | goto dma_err; | ||
422 | wrb = queue_head_node(txq); | 456 | wrb = queue_head_node(txq); |
423 | wrb_fill(wrb, busaddr, frag->size); | 457 | wrb_fill(wrb, busaddr, frag->size); |
424 | be_dws_cpu_to_le(wrb, sizeof(*wrb)); | 458 | be_dws_cpu_to_le(wrb, sizeof(*wrb)); |
@@ -438,6 +472,16 @@ static int make_tx_wrbs(struct be_adapter *adapter, | |||
438 | be_dws_cpu_to_le(hdr, sizeof(*hdr)); | 472 | be_dws_cpu_to_le(hdr, sizeof(*hdr)); |
439 | 473 | ||
440 | return copied; | 474 | return copied; |
475 | dma_err: | ||
476 | txq->head = map_head; | ||
477 | while (copied) { | ||
478 | wrb = queue_head_node(txq); | ||
479 | unmap_tx_frag(pdev, wrb, map_single); | ||
480 | map_single = false; | ||
481 | copied -= wrb->frag_len; | ||
482 | queue_head_inc(txq); | ||
483 | } | ||
484 | return 0; | ||
441 | } | 485 | } |
442 | 486 | ||
443 | static netdev_tx_t be_xmit(struct sk_buff *skb, | 487 | static netdev_tx_t be_xmit(struct sk_buff *skb, |
@@ -462,6 +506,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, | |||
462 | * *BEFORE* ringing the tx doorbell, so that we serialze the | 506 | * *BEFORE* ringing the tx doorbell, so that we serialze the |
463 | * tx compls of the current transmit which'll wake up the queue | 507 | * tx compls of the current transmit which'll wake up the queue |
464 | */ | 508 | */ |
509 | atomic_add(wrb_cnt, &txq->used); | ||
465 | if ((BE_MAX_TX_FRAG_COUNT + atomic_read(&txq->used)) >= | 510 | if ((BE_MAX_TX_FRAG_COUNT + atomic_read(&txq->used)) >= |
466 | txq->len) { | 511 | txq->len) { |
467 | netif_stop_queue(netdev); | 512 | netif_stop_queue(netdev); |
@@ -541,6 +586,9 @@ static void be_vlan_add_vid(struct net_device *netdev, u16 vid) | |||
541 | { | 586 | { |
542 | struct be_adapter *adapter = netdev_priv(netdev); | 587 | struct be_adapter *adapter = netdev_priv(netdev); |
543 | 588 | ||
589 | if (!be_physfn(adapter)) | ||
590 | return; | ||
591 | |||
544 | adapter->vlan_tag[vid] = 1; | 592 | adapter->vlan_tag[vid] = 1; |
545 | adapter->vlans_added++; | 593 | adapter->vlans_added++; |
546 | if (adapter->vlans_added <= (adapter->max_vlans + 1)) | 594 | if (adapter->vlans_added <= (adapter->max_vlans + 1)) |
@@ -551,6 +599,9 @@ static void be_vlan_rem_vid(struct net_device *netdev, u16 vid) | |||
551 | { | 599 | { |
552 | struct be_adapter *adapter = netdev_priv(netdev); | 600 | struct be_adapter *adapter = netdev_priv(netdev); |
553 | 601 | ||
602 | if (!be_physfn(adapter)) | ||
603 | return; | ||
604 | |||
554 | adapter->vlan_tag[vid] = 0; | 605 | adapter->vlan_tag[vid] = 0; |
555 | vlan_group_set_device(adapter->vlan_grp, vid, NULL); | 606 | vlan_group_set_device(adapter->vlan_grp, vid, NULL); |
556 | adapter->vlans_added--; | 607 | adapter->vlans_added--; |
@@ -588,6 +639,28 @@ done: | |||
588 | return; | 639 | return; |
589 | } | 640 | } |
590 | 641 | ||
642 | static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) | ||
643 | { | ||
644 | struct be_adapter *adapter = netdev_priv(netdev); | ||
645 | int status; | ||
646 | |||
647 | if (!adapter->sriov_enabled) | ||
648 | return -EPERM; | ||
649 | |||
650 | if (!is_valid_ether_addr(mac) || (vf >= num_vfs)) | ||
651 | return -EINVAL; | ||
652 | |||
653 | status = be_cmd_pmac_del(adapter, adapter->vf_if_handle[vf], | ||
654 | adapter->vf_pmac_id[vf]); | ||
655 | |||
656 | status = be_cmd_pmac_add(adapter, mac, adapter->vf_if_handle[vf], | ||
657 | &adapter->vf_pmac_id[vf]); | ||
658 | if (!status) | ||
659 | dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", | ||
660 | mac, vf); | ||
661 | return status; | ||
662 | } | ||
663 | |||
591 | static void be_rx_rate_update(struct be_adapter *adapter) | 664 | static void be_rx_rate_update(struct be_adapter *adapter) |
592 | { | 665 | { |
593 | struct be_drvr_stats *stats = drvr_stats(adapter); | 666 | struct be_drvr_stats *stats = drvr_stats(adapter); |
@@ -647,7 +720,7 @@ get_rx_page_info(struct be_adapter *adapter, u16 frag_idx) | |||
647 | BUG_ON(!rx_page_info->page); | 720 | BUG_ON(!rx_page_info->page); |
648 | 721 | ||
649 | if (rx_page_info->last_page_user) { | 722 | if (rx_page_info->last_page_user) { |
650 | pci_unmap_page(adapter->pdev, pci_unmap_addr(rx_page_info, bus), | 723 | pci_unmap_page(adapter->pdev, dma_unmap_addr(rx_page_info, bus), |
651 | adapter->big_page_size, PCI_DMA_FROMDEVICE); | 724 | adapter->big_page_size, PCI_DMA_FROMDEVICE); |
652 | rx_page_info->last_page_user = false; | 725 | rx_page_info->last_page_user = false; |
653 | } | 726 | } |
@@ -757,7 +830,6 @@ static void skb_fill_rx_data(struct be_adapter *adapter, | |||
757 | 830 | ||
758 | done: | 831 | done: |
759 | be_rx_stats_update(adapter, pktsize, num_rcvd); | 832 | be_rx_stats_update(adapter, pktsize, num_rcvd); |
760 | return; | ||
761 | } | 833 | } |
762 | 834 | ||
763 | /* Process the RX completion indicated by rxcp when GRO is disabled */ | 835 | /* Process the RX completion indicated by rxcp when GRO is disabled */ |
@@ -791,7 +863,6 @@ static void be_rx_compl_process(struct be_adapter *adapter, | |||
791 | 863 | ||
792 | skb->truesize = skb->len + sizeof(struct sk_buff); | 864 | skb->truesize = skb->len + sizeof(struct sk_buff); |
793 | skb->protocol = eth_type_trans(skb, adapter->netdev); | 865 | skb->protocol = eth_type_trans(skb, adapter->netdev); |
794 | skb->dev = adapter->netdev; | ||
795 | 866 | ||
796 | vlanf = AMAP_GET_BITS(struct amap_eth_rx_compl, vtp, rxcp); | 867 | vlanf = AMAP_GET_BITS(struct amap_eth_rx_compl, vtp, rxcp); |
797 | vtm = AMAP_GET_BITS(struct amap_eth_rx_compl, vtm, rxcp); | 868 | vtm = AMAP_GET_BITS(struct amap_eth_rx_compl, vtm, rxcp); |
@@ -812,8 +883,6 @@ static void be_rx_compl_process(struct be_adapter *adapter, | |||
812 | } else { | 883 | } else { |
813 | netif_receive_skb(skb); | 884 | netif_receive_skb(skb); |
814 | } | 885 | } |
815 | |||
816 | return; | ||
817 | } | 886 | } |
818 | 887 | ||
819 | /* Process the RX completion indicated by rxcp when GRO is enabled */ | 888 | /* Process the RX completion indicated by rxcp when GRO is enabled */ |
@@ -893,7 +962,6 @@ static void be_rx_compl_process_gro(struct be_adapter *adapter, | |||
893 | } | 962 | } |
894 | 963 | ||
895 | be_rx_stats_update(adapter, pkt_size, num_rcvd); | 964 | be_rx_stats_update(adapter, pkt_size, num_rcvd); |
896 | return; | ||
897 | } | 965 | } |
898 | 966 | ||
899 | static struct be_eth_rx_compl *be_rx_compl_get(struct be_adapter *adapter) | 967 | static struct be_eth_rx_compl *be_rx_compl_get(struct be_adapter *adapter) |
@@ -959,7 +1027,7 @@ static void be_post_rx_frags(struct be_adapter *adapter) | |||
959 | } | 1027 | } |
960 | page_offset = page_info->page_offset; | 1028 | page_offset = page_info->page_offset; |
961 | page_info->page = pagep; | 1029 | page_info->page = pagep; |
962 | pci_unmap_addr_set(page_info, bus, page_dmaaddr); | 1030 | dma_unmap_addr_set(page_info, bus, page_dmaaddr); |
963 | frag_dmaaddr = page_dmaaddr + page_info->page_offset; | 1031 | frag_dmaaddr = page_dmaaddr + page_info->page_offset; |
964 | 1032 | ||
965 | rxd = queue_head_node(rxq); | 1033 | rxd = queue_head_node(rxq); |
@@ -987,8 +1055,6 @@ static void be_post_rx_frags(struct be_adapter *adapter) | |||
987 | /* Let be_worker replenish when memory is available */ | 1055 | /* Let be_worker replenish when memory is available */ |
988 | adapter->rx_post_starved = true; | 1056 | adapter->rx_post_starved = true; |
989 | } | 1057 | } |
990 | |||
991 | return; | ||
992 | } | 1058 | } |
993 | 1059 | ||
994 | static struct be_eth_tx_compl *be_tx_compl_get(struct be_queue_info *tx_cq) | 1060 | static struct be_eth_tx_compl *be_tx_compl_get(struct be_queue_info *tx_cq) |
@@ -1012,35 +1078,26 @@ static void be_tx_compl_process(struct be_adapter *adapter, u16 last_index) | |||
1012 | struct be_eth_wrb *wrb; | 1078 | struct be_eth_wrb *wrb; |
1013 | struct sk_buff **sent_skbs = adapter->tx_obj.sent_skb_list; | 1079 | struct sk_buff **sent_skbs = adapter->tx_obj.sent_skb_list; |
1014 | struct sk_buff *sent_skb; | 1080 | struct sk_buff *sent_skb; |
1015 | u64 busaddr; | 1081 | u16 cur_index, num_wrbs = 1; /* account for hdr wrb */ |
1016 | u16 cur_index, num_wrbs = 0; | 1082 | bool unmap_skb_hdr = true; |
1017 | 1083 | ||
1018 | cur_index = txq->tail; | 1084 | sent_skb = sent_skbs[txq->tail]; |
1019 | sent_skb = sent_skbs[cur_index]; | ||
1020 | BUG_ON(!sent_skb); | 1085 | BUG_ON(!sent_skb); |
1021 | sent_skbs[cur_index] = NULL; | 1086 | sent_skbs[txq->tail] = NULL; |
1022 | wrb = queue_tail_node(txq); | 1087 | |
1023 | be_dws_le_to_cpu(wrb, sizeof(*wrb)); | 1088 | /* skip header wrb */ |
1024 | busaddr = ((u64)wrb->frag_pa_hi << 32) | (u64)wrb->frag_pa_lo; | ||
1025 | if (busaddr != 0) { | ||
1026 | pci_unmap_single(adapter->pdev, busaddr, | ||
1027 | wrb->frag_len, PCI_DMA_TODEVICE); | ||
1028 | } | ||
1029 | num_wrbs++; | ||
1030 | queue_tail_inc(txq); | 1089 | queue_tail_inc(txq); |
1031 | 1090 | ||
1032 | while (cur_index != last_index) { | 1091 | do { |
1033 | cur_index = txq->tail; | 1092 | cur_index = txq->tail; |
1034 | wrb = queue_tail_node(txq); | 1093 | wrb = queue_tail_node(txq); |
1035 | be_dws_le_to_cpu(wrb, sizeof(*wrb)); | 1094 | unmap_tx_frag(adapter->pdev, wrb, (unmap_skb_hdr && |
1036 | busaddr = ((u64)wrb->frag_pa_hi << 32) | (u64)wrb->frag_pa_lo; | 1095 | skb_headlen(sent_skb))); |
1037 | if (busaddr != 0) { | 1096 | unmap_skb_hdr = false; |
1038 | pci_unmap_page(adapter->pdev, busaddr, | 1097 | |
1039 | wrb->frag_len, PCI_DMA_TODEVICE); | ||
1040 | } | ||
1041 | num_wrbs++; | 1098 | num_wrbs++; |
1042 | queue_tail_inc(txq); | 1099 | queue_tail_inc(txq); |
1043 | } | 1100 | } while (cur_index != last_index); |
1044 | 1101 | ||
1045 | atomic_sub(num_wrbs, &txq->used); | 1102 | atomic_sub(num_wrbs, &txq->used); |
1046 | 1103 | ||
@@ -1255,6 +1312,8 @@ static int be_tx_queues_create(struct be_adapter *adapter) | |||
1255 | /* Ask BE to create Tx Event queue */ | 1312 | /* Ask BE to create Tx Event queue */ |
1256 | if (be_cmd_eq_create(adapter, eq, adapter->tx_eq.cur_eqd)) | 1313 | if (be_cmd_eq_create(adapter, eq, adapter->tx_eq.cur_eqd)) |
1257 | goto tx_eq_free; | 1314 | goto tx_eq_free; |
1315 | adapter->base_eq_id = adapter->tx_eq.q.id; | ||
1316 | |||
1258 | /* Alloc TX eth compl queue */ | 1317 | /* Alloc TX eth compl queue */ |
1259 | cq = &adapter->tx_obj.cq; | 1318 | cq = &adapter->tx_obj.cq; |
1260 | if (be_queue_alloc(adapter, cq, TX_CQ_LEN, | 1319 | if (be_queue_alloc(adapter, cq, TX_CQ_LEN, |
@@ -1382,7 +1441,7 @@ rx_eq_free: | |||
1382 | /* There are 8 evt ids per func. Retruns the evt id's bit number */ | 1441 | /* There are 8 evt ids per func. Retruns the evt id's bit number */ |
1383 | static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id) | 1442 | static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id) |
1384 | { | 1443 | { |
1385 | return eq_id % 8; | 1444 | return eq_id - adapter->base_eq_id; |
1386 | } | 1445 | } |
1387 | 1446 | ||
1388 | static irqreturn_t be_intx(int irq, void *dev) | 1447 | static irqreturn_t be_intx(int irq, void *dev) |
@@ -1557,7 +1616,27 @@ static void be_msix_enable(struct be_adapter *adapter) | |||
1557 | BE_NUM_MSIX_VECTORS); | 1616 | BE_NUM_MSIX_VECTORS); |
1558 | if (status == 0) | 1617 | if (status == 0) |
1559 | adapter->msix_enabled = true; | 1618 | adapter->msix_enabled = true; |
1560 | return; | 1619 | } |
1620 | |||
1621 | static void be_sriov_enable(struct be_adapter *adapter) | ||
1622 | { | ||
1623 | #ifdef CONFIG_PCI_IOV | ||
1624 | int status; | ||
1625 | if (be_physfn(adapter) && num_vfs) { | ||
1626 | status = pci_enable_sriov(adapter->pdev, num_vfs); | ||
1627 | adapter->sriov_enabled = status ? false : true; | ||
1628 | } | ||
1629 | #endif | ||
1630 | } | ||
1631 | |||
1632 | static void be_sriov_disable(struct be_adapter *adapter) | ||
1633 | { | ||
1634 | #ifdef CONFIG_PCI_IOV | ||
1635 | if (adapter->sriov_enabled) { | ||
1636 | pci_disable_sriov(adapter->pdev); | ||
1637 | adapter->sriov_enabled = false; | ||
1638 | } | ||
1639 | #endif | ||
1561 | } | 1640 | } |
1562 | 1641 | ||
1563 | static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) | 1642 | static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) |
@@ -1617,6 +1696,9 @@ static int be_irq_register(struct be_adapter *adapter) | |||
1617 | status = be_msix_register(adapter); | 1696 | status = be_msix_register(adapter); |
1618 | if (status == 0) | 1697 | if (status == 0) |
1619 | goto done; | 1698 | goto done; |
1699 | /* INTx is not supported for VF */ | ||
1700 | if (!be_physfn(adapter)) | ||
1701 | return status; | ||
1620 | } | 1702 | } |
1621 | 1703 | ||
1622 | /* INTx */ | 1704 | /* INTx */ |
@@ -1651,7 +1733,6 @@ static void be_irq_unregister(struct be_adapter *adapter) | |||
1651 | be_free_irq(adapter, &adapter->rx_eq); | 1733 | be_free_irq(adapter, &adapter->rx_eq); |
1652 | done: | 1734 | done: |
1653 | adapter->isr_registered = false; | 1735 | adapter->isr_registered = false; |
1654 | return; | ||
1655 | } | 1736 | } |
1656 | 1737 | ||
1657 | static int be_open(struct net_device *netdev) | 1738 | static int be_open(struct net_device *netdev) |
@@ -1690,14 +1771,17 @@ static int be_open(struct net_device *netdev) | |||
1690 | goto ret_sts; | 1771 | goto ret_sts; |
1691 | be_link_status_update(adapter, link_up); | 1772 | be_link_status_update(adapter, link_up); |
1692 | 1773 | ||
1693 | status = be_vid_config(adapter); | 1774 | if (be_physfn(adapter)) |
1775 | status = be_vid_config(adapter); | ||
1694 | if (status) | 1776 | if (status) |
1695 | goto ret_sts; | 1777 | goto ret_sts; |
1696 | 1778 | ||
1697 | status = be_cmd_set_flow_control(adapter, | 1779 | if (be_physfn(adapter)) { |
1698 | adapter->tx_fc, adapter->rx_fc); | 1780 | status = be_cmd_set_flow_control(adapter, |
1699 | if (status) | 1781 | adapter->tx_fc, adapter->rx_fc); |
1700 | goto ret_sts; | 1782 | if (status) |
1783 | goto ret_sts; | ||
1784 | } | ||
1701 | 1785 | ||
1702 | schedule_delayed_work(&adapter->work, msecs_to_jiffies(100)); | 1786 | schedule_delayed_work(&adapter->work, msecs_to_jiffies(100)); |
1703 | ret_sts: | 1787 | ret_sts: |
@@ -1723,7 +1807,7 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable) | |||
1723 | PCICFG_PM_CONTROL_OFFSET, PCICFG_PM_CONTROL_MASK); | 1807 | PCICFG_PM_CONTROL_OFFSET, PCICFG_PM_CONTROL_MASK); |
1724 | if (status) { | 1808 | if (status) { |
1725 | dev_err(&adapter->pdev->dev, | 1809 | dev_err(&adapter->pdev->dev, |
1726 | "Could not enable Wake-on-lan \n"); | 1810 | "Could not enable Wake-on-lan\n"); |
1727 | pci_free_consistent(adapter->pdev, cmd.size, cmd.va, | 1811 | pci_free_consistent(adapter->pdev, cmd.size, cmd.va, |
1728 | cmd.dma); | 1812 | cmd.dma); |
1729 | return status; | 1813 | return status; |
@@ -1745,22 +1829,48 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable) | |||
1745 | static int be_setup(struct be_adapter *adapter) | 1829 | static int be_setup(struct be_adapter *adapter) |
1746 | { | 1830 | { |
1747 | struct net_device *netdev = adapter->netdev; | 1831 | struct net_device *netdev = adapter->netdev; |
1748 | u32 cap_flags, en_flags; | 1832 | u32 cap_flags, en_flags, vf = 0; |
1749 | int status; | 1833 | int status; |
1834 | u8 mac[ETH_ALEN]; | ||
1835 | |||
1836 | cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST; | ||
1750 | 1837 | ||
1751 | cap_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | | 1838 | if (be_physfn(adapter)) { |
1752 | BE_IF_FLAGS_MCAST_PROMISCUOUS | | 1839 | cap_flags |= BE_IF_FLAGS_MCAST_PROMISCUOUS | |
1753 | BE_IF_FLAGS_PROMISCUOUS | | 1840 | BE_IF_FLAGS_PROMISCUOUS | |
1754 | BE_IF_FLAGS_PASS_L3L4_ERRORS; | 1841 | BE_IF_FLAGS_PASS_L3L4_ERRORS; |
1755 | en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | | 1842 | en_flags |= BE_IF_FLAGS_PASS_L3L4_ERRORS; |
1756 | BE_IF_FLAGS_PASS_L3L4_ERRORS; | 1843 | } |
1757 | 1844 | ||
1758 | status = be_cmd_if_create(adapter, cap_flags, en_flags, | 1845 | status = be_cmd_if_create(adapter, cap_flags, en_flags, |
1759 | netdev->dev_addr, false/* pmac_invalid */, | 1846 | netdev->dev_addr, false/* pmac_invalid */, |
1760 | &adapter->if_handle, &adapter->pmac_id); | 1847 | &adapter->if_handle, &adapter->pmac_id, 0); |
1761 | if (status != 0) | 1848 | if (status != 0) |
1762 | goto do_none; | 1849 | goto do_none; |
1763 | 1850 | ||
1851 | if (be_physfn(adapter)) { | ||
1852 | while (vf < num_vfs) { | ||
1853 | cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | ||
1854 | | BE_IF_FLAGS_BROADCAST; | ||
1855 | status = be_cmd_if_create(adapter, cap_flags, en_flags, | ||
1856 | mac, true, &adapter->vf_if_handle[vf], | ||
1857 | NULL, vf+1); | ||
1858 | if (status) { | ||
1859 | dev_err(&adapter->pdev->dev, | ||
1860 | "Interface Create failed for VF %d\n", vf); | ||
1861 | goto if_destroy; | ||
1862 | } | ||
1863 | vf++; | ||
1864 | } while (vf < num_vfs); | ||
1865 | } else if (!be_physfn(adapter)) { | ||
1866 | status = be_cmd_mac_addr_query(adapter, mac, | ||
1867 | MAC_ADDRESS_TYPE_NETWORK, false, adapter->if_handle); | ||
1868 | if (!status) { | ||
1869 | memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); | ||
1870 | memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); | ||
1871 | } | ||
1872 | } | ||
1873 | |||
1764 | status = be_tx_queues_create(adapter); | 1874 | status = be_tx_queues_create(adapter); |
1765 | if (status != 0) | 1875 | if (status != 0) |
1766 | goto if_destroy; | 1876 | goto if_destroy; |
@@ -1782,6 +1892,9 @@ rx_qs_destroy: | |||
1782 | tx_qs_destroy: | 1892 | tx_qs_destroy: |
1783 | be_tx_queues_destroy(adapter); | 1893 | be_tx_queues_destroy(adapter); |
1784 | if_destroy: | 1894 | if_destroy: |
1895 | for (vf = 0; vf < num_vfs; vf++) | ||
1896 | if (adapter->vf_if_handle[vf]) | ||
1897 | be_cmd_if_destroy(adapter, adapter->vf_if_handle[vf]); | ||
1785 | be_cmd_if_destroy(adapter, adapter->if_handle); | 1898 | be_cmd_if_destroy(adapter, adapter->if_handle); |
1786 | do_none: | 1899 | do_none: |
1787 | return status; | 1900 | return status; |
@@ -2061,6 +2174,7 @@ static struct net_device_ops be_netdev_ops = { | |||
2061 | .ndo_vlan_rx_register = be_vlan_register, | 2174 | .ndo_vlan_rx_register = be_vlan_register, |
2062 | .ndo_vlan_rx_add_vid = be_vlan_add_vid, | 2175 | .ndo_vlan_rx_add_vid = be_vlan_add_vid, |
2063 | .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, | 2176 | .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, |
2177 | .ndo_set_vf_mac = be_set_vf_mac | ||
2064 | }; | 2178 | }; |
2065 | 2179 | ||
2066 | static void be_netdev_init(struct net_device *netdev) | 2180 | static void be_netdev_init(struct net_device *netdev) |
@@ -2102,37 +2216,48 @@ static void be_unmap_pci_bars(struct be_adapter *adapter) | |||
2102 | iounmap(adapter->csr); | 2216 | iounmap(adapter->csr); |
2103 | if (adapter->db) | 2217 | if (adapter->db) |
2104 | iounmap(adapter->db); | 2218 | iounmap(adapter->db); |
2105 | if (adapter->pcicfg) | 2219 | if (adapter->pcicfg && be_physfn(adapter)) |
2106 | iounmap(adapter->pcicfg); | 2220 | iounmap(adapter->pcicfg); |
2107 | } | 2221 | } |
2108 | 2222 | ||
2109 | static int be_map_pci_bars(struct be_adapter *adapter) | 2223 | static int be_map_pci_bars(struct be_adapter *adapter) |
2110 | { | 2224 | { |
2111 | u8 __iomem *addr; | 2225 | u8 __iomem *addr; |
2112 | int pcicfg_reg; | 2226 | int pcicfg_reg, db_reg; |
2113 | 2227 | ||
2114 | addr = ioremap_nocache(pci_resource_start(adapter->pdev, 2), | 2228 | if (be_physfn(adapter)) { |
2115 | pci_resource_len(adapter->pdev, 2)); | 2229 | addr = ioremap_nocache(pci_resource_start(adapter->pdev, 2), |
2116 | if (addr == NULL) | 2230 | pci_resource_len(adapter->pdev, 2)); |
2117 | return -ENOMEM; | 2231 | if (addr == NULL) |
2118 | adapter->csr = addr; | 2232 | return -ENOMEM; |
2119 | 2233 | adapter->csr = addr; | |
2120 | addr = ioremap_nocache(pci_resource_start(adapter->pdev, 4), | 2234 | } |
2121 | 128 * 1024); | ||
2122 | if (addr == NULL) | ||
2123 | goto pci_map_err; | ||
2124 | adapter->db = addr; | ||
2125 | 2235 | ||
2126 | if (adapter->generation == BE_GEN2) | 2236 | if (adapter->generation == BE_GEN2) { |
2127 | pcicfg_reg = 1; | 2237 | pcicfg_reg = 1; |
2128 | else | 2238 | db_reg = 4; |
2239 | } else { | ||
2129 | pcicfg_reg = 0; | 2240 | pcicfg_reg = 0; |
2130 | 2241 | if (be_physfn(adapter)) | |
2131 | addr = ioremap_nocache(pci_resource_start(adapter->pdev, pcicfg_reg), | 2242 | db_reg = 4; |
2132 | pci_resource_len(adapter->pdev, pcicfg_reg)); | 2243 | else |
2244 | db_reg = 0; | ||
2245 | } | ||
2246 | addr = ioremap_nocache(pci_resource_start(adapter->pdev, db_reg), | ||
2247 | pci_resource_len(adapter->pdev, db_reg)); | ||
2133 | if (addr == NULL) | 2248 | if (addr == NULL) |
2134 | goto pci_map_err; | 2249 | goto pci_map_err; |
2135 | adapter->pcicfg = addr; | 2250 | adapter->db = addr; |
2251 | |||
2252 | if (be_physfn(adapter)) { | ||
2253 | addr = ioremap_nocache( | ||
2254 | pci_resource_start(adapter->pdev, pcicfg_reg), | ||
2255 | pci_resource_len(adapter->pdev, pcicfg_reg)); | ||
2256 | if (addr == NULL) | ||
2257 | goto pci_map_err; | ||
2258 | adapter->pcicfg = addr; | ||
2259 | } else | ||
2260 | adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET; | ||
2136 | 2261 | ||
2137 | return 0; | 2262 | return 0; |
2138 | pci_map_err: | 2263 | pci_map_err: |
@@ -2246,6 +2371,8 @@ static void __devexit be_remove(struct pci_dev *pdev) | |||
2246 | 2371 | ||
2247 | be_ctrl_cleanup(adapter); | 2372 | be_ctrl_cleanup(adapter); |
2248 | 2373 | ||
2374 | be_sriov_disable(adapter); | ||
2375 | |||
2249 | be_msix_disable(adapter); | 2376 | be_msix_disable(adapter); |
2250 | 2377 | ||
2251 | pci_set_drvdata(pdev, NULL); | 2378 | pci_set_drvdata(pdev, NULL); |
@@ -2270,16 +2397,20 @@ static int be_get_config(struct be_adapter *adapter) | |||
2270 | return status; | 2397 | return status; |
2271 | 2398 | ||
2272 | memset(mac, 0, ETH_ALEN); | 2399 | memset(mac, 0, ETH_ALEN); |
2273 | status = be_cmd_mac_addr_query(adapter, mac, | 2400 | |
2401 | if (be_physfn(adapter)) { | ||
2402 | status = be_cmd_mac_addr_query(adapter, mac, | ||
2274 | MAC_ADDRESS_TYPE_NETWORK, true /*permanent */, 0); | 2403 | MAC_ADDRESS_TYPE_NETWORK, true /*permanent */, 0); |
2275 | if (status) | ||
2276 | return status; | ||
2277 | 2404 | ||
2278 | if (!is_valid_ether_addr(mac)) | 2405 | if (status) |
2279 | return -EADDRNOTAVAIL; | 2406 | return status; |
2280 | 2407 | ||
2281 | memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); | 2408 | if (!is_valid_ether_addr(mac)) |
2282 | memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); | 2409 | return -EADDRNOTAVAIL; |
2410 | |||
2411 | memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); | ||
2412 | memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); | ||
2413 | } | ||
2283 | 2414 | ||
2284 | if (adapter->cap & 0x400) | 2415 | if (adapter->cap & 0x400) |
2285 | adapter->max_vlans = BE_NUM_VLANS_SUPPORTED/4; | 2416 | adapter->max_vlans = BE_NUM_VLANS_SUPPORTED/4; |
@@ -2296,6 +2427,7 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
2296 | struct be_adapter *adapter; | 2427 | struct be_adapter *adapter; |
2297 | struct net_device *netdev; | 2428 | struct net_device *netdev; |
2298 | 2429 | ||
2430 | |||
2299 | status = pci_enable_device(pdev); | 2431 | status = pci_enable_device(pdev); |
2300 | if (status) | 2432 | if (status) |
2301 | goto do_none; | 2433 | goto do_none; |
@@ -2344,24 +2476,28 @@ static int __devinit be_probe(struct pci_dev *pdev, | |||
2344 | } | 2476 | } |
2345 | } | 2477 | } |
2346 | 2478 | ||
2479 | be_sriov_enable(adapter); | ||
2480 | |||
2347 | status = be_ctrl_init(adapter); | 2481 | status = be_ctrl_init(adapter); |
2348 | if (status) | 2482 | if (status) |
2349 | goto free_netdev; | 2483 | goto free_netdev; |
2350 | 2484 | ||
2351 | /* sync up with fw's ready state */ | 2485 | /* sync up with fw's ready state */ |
2352 | status = be_cmd_POST(adapter); | 2486 | if (be_physfn(adapter)) { |
2353 | if (status) | 2487 | status = be_cmd_POST(adapter); |
2354 | goto ctrl_clean; | 2488 | if (status) |
2489 | goto ctrl_clean; | ||
2490 | |||
2491 | status = be_cmd_reset_function(adapter); | ||
2492 | if (status) | ||
2493 | goto ctrl_clean; | ||
2494 | } | ||
2355 | 2495 | ||
2356 | /* tell fw we're ready to fire cmds */ | 2496 | /* tell fw we're ready to fire cmds */ |
2357 | status = be_cmd_fw_init(adapter); | 2497 | status = be_cmd_fw_init(adapter); |
2358 | if (status) | 2498 | if (status) |
2359 | goto ctrl_clean; | 2499 | goto ctrl_clean; |
2360 | 2500 | ||
2361 | status = be_cmd_reset_function(adapter); | ||
2362 | if (status) | ||
2363 | goto ctrl_clean; | ||
2364 | |||
2365 | status = be_stats_init(adapter); | 2501 | status = be_stats_init(adapter); |
2366 | if (status) | 2502 | if (status) |
2367 | goto ctrl_clean; | 2503 | goto ctrl_clean; |
@@ -2391,6 +2527,7 @@ ctrl_clean: | |||
2391 | be_ctrl_cleanup(adapter); | 2527 | be_ctrl_cleanup(adapter); |
2392 | free_netdev: | 2528 | free_netdev: |
2393 | be_msix_disable(adapter); | 2529 | be_msix_disable(adapter); |
2530 | be_sriov_disable(adapter); | ||
2394 | free_netdev(adapter->netdev); | 2531 | free_netdev(adapter->netdev); |
2395 | pci_set_drvdata(pdev, NULL); | 2532 | pci_set_drvdata(pdev, NULL); |
2396 | rel_reg: | 2533 | rel_reg: |
@@ -2474,8 +2611,6 @@ static void be_shutdown(struct pci_dev *pdev) | |||
2474 | be_setup_wol(adapter, true); | 2611 | be_setup_wol(adapter, true); |
2475 | 2612 | ||
2476 | pci_disable_device(pdev); | 2613 | pci_disable_device(pdev); |
2477 | |||
2478 | return; | ||
2479 | } | 2614 | } |
2480 | 2615 | ||
2481 | static pci_ers_result_t be_eeh_err_detected(struct pci_dev *pdev, | 2616 | static pci_ers_result_t be_eeh_err_detected(struct pci_dev *pdev, |
@@ -2557,7 +2692,6 @@ static void be_eeh_resume(struct pci_dev *pdev) | |||
2557 | return; | 2692 | return; |
2558 | err: | 2693 | err: |
2559 | dev_err(&adapter->pdev->dev, "EEH resume failed\n"); | 2694 | dev_err(&adapter->pdev->dev, "EEH resume failed\n"); |
2560 | return; | ||
2561 | } | 2695 | } |
2562 | 2696 | ||
2563 | static struct pci_error_handlers be_eeh_handlers = { | 2697 | static struct pci_error_handlers be_eeh_handlers = { |
@@ -2587,6 +2721,13 @@ static int __init be_init_module(void) | |||
2587 | rx_frag_size = 2048; | 2721 | rx_frag_size = 2048; |
2588 | } | 2722 | } |
2589 | 2723 | ||
2724 | if (num_vfs > 32) { | ||
2725 | printk(KERN_WARNING DRV_NAME | ||
2726 | " : Module param num_vfs must not be greater than 32." | ||
2727 | "Using 32\n"); | ||
2728 | num_vfs = 32; | ||
2729 | } | ||
2730 | |||
2590 | return pci_register_driver(&be_driver); | 2731 | return pci_register_driver(&be_driver); |
2591 | } | 2732 | } |
2592 | module_init(be_init_module); | 2733 | module_init(be_init_module); |