diff options
Diffstat (limited to 'drivers/net/benet')
-rw-r--r-- | drivers/net/benet/be.h | 1 | ||||
-rw-r--r-- | drivers/net/benet/be_main.c | 54 |
2 files changed, 47 insertions, 8 deletions
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h index a8e95da23f7b..f693b9ed68a4 100644 --- a/drivers/net/benet/be.h +++ b/drivers/net/benet/be.h | |||
@@ -224,6 +224,7 @@ struct be_vf_cfg { | |||
224 | unsigned char vf_mac_addr[ETH_ALEN]; | 224 | unsigned char vf_mac_addr[ETH_ALEN]; |
225 | u32 vf_if_handle; | 225 | u32 vf_if_handle; |
226 | u32 vf_pmac_id; | 226 | u32 vf_pmac_id; |
227 | u16 vf_vlan_tag; | ||
227 | }; | 228 | }; |
228 | 229 | ||
229 | #define BE_NUM_MSIX_VECTORS 2 /* 1 each for Tx and Rx */ | 230 | #define BE_NUM_MSIX_VECTORS 2 /* 1 each for Tx and Rx */ |
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index a8c4548e0d60..46f087e3422b 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -552,11 +552,18 @@ static int be_change_mtu(struct net_device *netdev, int new_mtu) | |||
552 | * A max of 64 (BE_NUM_VLANS_SUPPORTED) vlans can be configured in BE. | 552 | * A max of 64 (BE_NUM_VLANS_SUPPORTED) vlans can be configured in BE. |
553 | * If the user configures more, place BE in vlan promiscuous mode. | 553 | * If the user configures more, place BE in vlan promiscuous mode. |
554 | */ | 554 | */ |
555 | static int be_vid_config(struct be_adapter *adapter) | 555 | static int be_vid_config(struct be_adapter *adapter, bool vf, u32 vf_num) |
556 | { | 556 | { |
557 | u16 vtag[BE_NUM_VLANS_SUPPORTED]; | 557 | u16 vtag[BE_NUM_VLANS_SUPPORTED]; |
558 | u16 ntags = 0, i; | 558 | u16 ntags = 0, i; |
559 | int status = 0; | 559 | int status = 0; |
560 | u32 if_handle; | ||
561 | |||
562 | if (vf) { | ||
563 | if_handle = adapter->vf_cfg[vf_num].vf_if_handle; | ||
564 | vtag[0] = cpu_to_le16(adapter->vf_cfg[vf_num].vf_vlan_tag); | ||
565 | status = be_cmd_vlan_config(adapter, if_handle, vtag, 1, 1, 0); | ||
566 | } | ||
560 | 567 | ||
561 | if (adapter->vlans_added <= adapter->max_vlans) { | 568 | if (adapter->vlans_added <= adapter->max_vlans) { |
562 | /* Construct VLAN Table to give to HW */ | 569 | /* Construct VLAN Table to give to HW */ |
@@ -572,6 +579,7 @@ static int be_vid_config(struct be_adapter *adapter) | |||
572 | status = be_cmd_vlan_config(adapter, adapter->if_handle, | 579 | status = be_cmd_vlan_config(adapter, adapter->if_handle, |
573 | NULL, 0, 1, 1); | 580 | NULL, 0, 1, 1); |
574 | } | 581 | } |
582 | |||
575 | return status; | 583 | return status; |
576 | } | 584 | } |
577 | 585 | ||
@@ -592,27 +600,28 @@ static void be_vlan_add_vid(struct net_device *netdev, u16 vid) | |||
592 | { | 600 | { |
593 | struct be_adapter *adapter = netdev_priv(netdev); | 601 | struct be_adapter *adapter = netdev_priv(netdev); |
594 | 602 | ||
603 | adapter->vlans_added++; | ||
595 | if (!be_physfn(adapter)) | 604 | if (!be_physfn(adapter)) |
596 | return; | 605 | return; |
597 | 606 | ||
598 | adapter->vlan_tag[vid] = 1; | 607 | adapter->vlan_tag[vid] = 1; |
599 | adapter->vlans_added++; | ||
600 | if (adapter->vlans_added <= (adapter->max_vlans + 1)) | 608 | if (adapter->vlans_added <= (adapter->max_vlans + 1)) |
601 | be_vid_config(adapter); | 609 | be_vid_config(adapter, false, 0); |
602 | } | 610 | } |
603 | 611 | ||
604 | static void be_vlan_rem_vid(struct net_device *netdev, u16 vid) | 612 | static void be_vlan_rem_vid(struct net_device *netdev, u16 vid) |
605 | { | 613 | { |
606 | struct be_adapter *adapter = netdev_priv(netdev); | 614 | struct be_adapter *adapter = netdev_priv(netdev); |
607 | 615 | ||
616 | adapter->vlans_added--; | ||
617 | vlan_group_set_device(adapter->vlan_grp, vid, NULL); | ||
618 | |||
608 | if (!be_physfn(adapter)) | 619 | if (!be_physfn(adapter)) |
609 | return; | 620 | return; |
610 | 621 | ||
611 | adapter->vlan_tag[vid] = 0; | 622 | adapter->vlan_tag[vid] = 0; |
612 | vlan_group_set_device(adapter->vlan_grp, vid, NULL); | ||
613 | adapter->vlans_added--; | ||
614 | if (adapter->vlans_added <= adapter->max_vlans) | 623 | if (adapter->vlans_added <= adapter->max_vlans) |
615 | be_vid_config(adapter); | 624 | be_vid_config(adapter, false, 0); |
616 | } | 625 | } |
617 | 626 | ||
618 | static void be_set_multicast_list(struct net_device *netdev) | 627 | static void be_set_multicast_list(struct net_device *netdev) |
@@ -687,13 +696,41 @@ static int be_get_vf_config(struct net_device *netdev, int vf, | |||
687 | 696 | ||
688 | vi->vf = vf; | 697 | vi->vf = vf; |
689 | vi->tx_rate = 0; | 698 | vi->tx_rate = 0; |
690 | vi->vlan = 0; | 699 | vi->vlan = adapter->vf_cfg[vf].vf_vlan_tag; |
691 | vi->qos = 0; | 700 | vi->qos = 0; |
692 | memcpy(&vi->mac, adapter->vf_cfg[vf].vf_mac_addr, ETH_ALEN); | 701 | memcpy(&vi->mac, adapter->vf_cfg[vf].vf_mac_addr, ETH_ALEN); |
693 | 702 | ||
694 | return 0; | 703 | return 0; |
695 | } | 704 | } |
696 | 705 | ||
706 | static int be_set_vf_vlan(struct net_device *netdev, | ||
707 | int vf, u16 vlan, u8 qos) | ||
708 | { | ||
709 | struct be_adapter *adapter = netdev_priv(netdev); | ||
710 | int status = 0; | ||
711 | |||
712 | if (!adapter->sriov_enabled) | ||
713 | return -EPERM; | ||
714 | |||
715 | if ((vf >= num_vfs) || (vlan > 4095)) | ||
716 | return -EINVAL; | ||
717 | |||
718 | if (vlan) { | ||
719 | adapter->vf_cfg[vf].vf_vlan_tag = vlan; | ||
720 | adapter->vlans_added++; | ||
721 | } else { | ||
722 | adapter->vf_cfg[vf].vf_vlan_tag = 0; | ||
723 | adapter->vlans_added--; | ||
724 | } | ||
725 | |||
726 | status = be_vid_config(adapter, true, vf); | ||
727 | |||
728 | if (status) | ||
729 | dev_info(&adapter->pdev->dev, | ||
730 | "VLAN %d config on VF %d failed\n", vlan, vf); | ||
731 | return status; | ||
732 | } | ||
733 | |||
697 | static void be_rx_rate_update(struct be_adapter *adapter) | 734 | static void be_rx_rate_update(struct be_adapter *adapter) |
698 | { | 735 | { |
699 | struct be_drvr_stats *stats = drvr_stats(adapter); | 736 | struct be_drvr_stats *stats = drvr_stats(adapter); |
@@ -1849,7 +1886,7 @@ static int be_open(struct net_device *netdev) | |||
1849 | be_link_status_update(adapter, link_up); | 1886 | be_link_status_update(adapter, link_up); |
1850 | 1887 | ||
1851 | if (be_physfn(adapter)) { | 1888 | if (be_physfn(adapter)) { |
1852 | status = be_vid_config(adapter); | 1889 | status = be_vid_config(adapter, false, 0); |
1853 | if (status) | 1890 | if (status) |
1854 | goto err; | 1891 | goto err; |
1855 | 1892 | ||
@@ -2218,6 +2255,7 @@ static struct net_device_ops be_netdev_ops = { | |||
2218 | .ndo_vlan_rx_add_vid = be_vlan_add_vid, | 2255 | .ndo_vlan_rx_add_vid = be_vlan_add_vid, |
2219 | .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, | 2256 | .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, |
2220 | .ndo_set_vf_mac = be_set_vf_mac, | 2257 | .ndo_set_vf_mac = be_set_vf_mac, |
2258 | .ndo_set_vf_vlan = be_set_vf_vlan, | ||
2221 | .ndo_get_vf_config = be_get_vf_config | 2259 | .ndo_get_vf_config = be_get_vf_config |
2222 | }; | 2260 | }; |
2223 | 2261 | ||