aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_main.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_main.c70
1 files changed, 19 insertions, 51 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index a0d148f590c2..f3923dec32b7 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -34,8 +34,6 @@ static const struct net_device_ops ice_netdev_ops;
34static void ice_rebuild(struct ice_pf *pf); 34static void ice_rebuild(struct ice_pf *pf);
35 35
36static void ice_vsi_release_all(struct ice_pf *pf); 36static void ice_vsi_release_all(struct ice_pf *pf);
37static void ice_update_vsi_stats(struct ice_vsi *vsi);
38static void ice_update_pf_stats(struct ice_pf *pf);
39 37
40/** 38/**
41 * ice_get_tx_pending - returns number of Tx descriptors not processed 39 * ice_get_tx_pending - returns number of Tx descriptors not processed
@@ -118,10 +116,9 @@ static void ice_check_for_hang_subtask(struct ice_pf *pf)
118 */ 116 */
119static int ice_init_mac_fltr(struct ice_pf *pf) 117static int ice_init_mac_fltr(struct ice_pf *pf)
120{ 118{
121 LIST_HEAD(tmp_add_list); 119 enum ice_status status;
122 u8 broadcast[ETH_ALEN]; 120 u8 broadcast[ETH_ALEN];
123 struct ice_vsi *vsi; 121 struct ice_vsi *vsi;
124 int status;
125 122
126 vsi = ice_find_vsi_by_type(pf, ICE_VSI_PF); 123 vsi = ice_find_vsi_by_type(pf, ICE_VSI_PF);
127 if (!vsi) 124 if (!vsi)
@@ -132,8 +129,7 @@ static int ice_init_mac_fltr(struct ice_pf *pf)
132 */ 129 */
133 130
134 /* Add a unicast MAC filter so the VSI can get its packets */ 131 /* Add a unicast MAC filter so the VSI can get its packets */
135 status = ice_add_mac_to_list(vsi, &tmp_add_list, 132 status = ice_vsi_cfg_mac_fltr(vsi, vsi->port_info->mac.perm_addr, true);
136 vsi->port_info->mac.perm_addr);
137 if (status) 133 if (status)
138 goto unregister; 134 goto unregister;
139 135
@@ -141,18 +137,11 @@ static int ice_init_mac_fltr(struct ice_pf *pf)
141 * MAC address to the list as well. 137 * MAC address to the list as well.
142 */ 138 */
143 eth_broadcast_addr(broadcast); 139 eth_broadcast_addr(broadcast);
144 status = ice_add_mac_to_list(vsi, &tmp_add_list, broadcast); 140 status = ice_vsi_cfg_mac_fltr(vsi, broadcast, true);
145 if (status)
146 goto free_mac_list;
147
148 /* Program MAC filters for entries in tmp_add_list */
149 status = ice_add_mac(&pf->hw, &tmp_add_list);
150 if (status) 141 if (status)
151 status = -ENOMEM; 142 goto unregister;
152
153free_mac_list:
154 ice_free_fltr_list(&pf->pdev->dev, &tmp_add_list);
155 143
144 return 0;
156unregister: 145unregister:
157 /* We aren't useful with no MAC filters, so unregister if we 146 /* We aren't useful with no MAC filters, so unregister if we
158 * had an error 147 * had an error
@@ -166,7 +155,7 @@ unregister:
166 vsi->netdev = NULL; 155 vsi->netdev = NULL;
167 } 156 }
168 157
169 return status; 158 return -EIO;
170} 159}
171 160
172/** 161/**
@@ -2836,10 +2825,8 @@ static int ice_set_mac_address(struct net_device *netdev, void *pi)
2836 struct ice_hw *hw = &pf->hw; 2825 struct ice_hw *hw = &pf->hw;
2837 struct sockaddr *addr = pi; 2826 struct sockaddr *addr = pi;
2838 enum ice_status status; 2827 enum ice_status status;
2839 LIST_HEAD(a_mac_list);
2840 LIST_HEAD(r_mac_list);
2841 u8 flags = 0; 2828 u8 flags = 0;
2842 int err; 2829 int err = 0;
2843 u8 *mac; 2830 u8 *mac;
2844 2831
2845 mac = (u8 *)addr->sa_data; 2832 mac = (u8 *)addr->sa_data;
@@ -2862,42 +2849,23 @@ static int ice_set_mac_address(struct net_device *netdev, void *pi)
2862 /* When we change the MAC address we also have to change the MAC address 2849 /* When we change the MAC address we also have to change the MAC address
2863 * based filter rules that were created previously for the old MAC 2850 * based filter rules that were created previously for the old MAC
2864 * address. So first, we remove the old filter rule using ice_remove_mac 2851 * address. So first, we remove the old filter rule using ice_remove_mac
2865 * and then create a new filter rule using ice_add_mac. Note that for 2852 * and then create a new filter rule using ice_add_mac via
2866 * both these operations, we first need to form a "list" of MAC 2853 * ice_vsi_cfg_mac_fltr function call for both add and/or remove
2867 * addresses (even though in this case, we have only 1 MAC address to be 2854 * filters.
2868 * added/removed) and this done using ice_add_mac_to_list. Depending on
2869 * the ensuing operation this "list" of MAC addresses is either to be
2870 * added or removed from the filter.
2871 */ 2855 */
2872 err = ice_add_mac_to_list(vsi, &r_mac_list, netdev->dev_addr); 2856 status = ice_vsi_cfg_mac_fltr(vsi, netdev->dev_addr, false);
2873 if (err) {
2874 err = -EADDRNOTAVAIL;
2875 goto free_lists;
2876 }
2877
2878 status = ice_remove_mac(hw, &r_mac_list);
2879 if (status) { 2857 if (status) {
2880 err = -EADDRNOTAVAIL; 2858 err = -EADDRNOTAVAIL;
2881 goto free_lists; 2859 goto err_update_filters;
2882 }
2883
2884 err = ice_add_mac_to_list(vsi, &a_mac_list, mac);
2885 if (err) {
2886 err = -EADDRNOTAVAIL;
2887 goto free_lists;
2888 } 2860 }
2889 2861
2890 status = ice_add_mac(hw, &a_mac_list); 2862 status = ice_vsi_cfg_mac_fltr(vsi, mac, true);
2891 if (status) { 2863 if (status) {
2892 err = -EADDRNOTAVAIL; 2864 err = -EADDRNOTAVAIL;
2893 goto free_lists; 2865 goto err_update_filters;
2894 } 2866 }
2895 2867
2896free_lists: 2868err_update_filters:
2897 /* free list entries */
2898 ice_free_fltr_list(&pf->pdev->dev, &r_mac_list);
2899 ice_free_fltr_list(&pf->pdev->dev, &a_mac_list);
2900
2901 if (err) { 2869 if (err) {
2902 netdev_err(netdev, "can't set MAC %pM. filter update failed\n", 2870 netdev_err(netdev, "can't set MAC %pM. filter update failed\n",
2903 mac); 2871 mac);
@@ -2913,8 +2881,8 @@ free_lists:
2913 flags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL; 2881 flags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL;
2914 status = ice_aq_manage_mac_write(hw, mac, flags, NULL); 2882 status = ice_aq_manage_mac_write(hw, mac, flags, NULL);
2915 if (status) { 2883 if (status) {
2916 netdev_err(netdev, "can't set MAC %pM. write to firmware failed.\n", 2884 netdev_err(netdev, "can't set MAC %pM. write to firmware failed error %d\n",
2917 mac); 2885 mac, status);
2918 } 2886 }
2919 return 0; 2887 return 0;
2920} 2888}
@@ -3254,7 +3222,7 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi)
3254 * ice_update_vsi_stats - Update VSI stats counters 3222 * ice_update_vsi_stats - Update VSI stats counters
3255 * @vsi: the VSI to be updated 3223 * @vsi: the VSI to be updated
3256 */ 3224 */
3257static void ice_update_vsi_stats(struct ice_vsi *vsi) 3225void ice_update_vsi_stats(struct ice_vsi *vsi)
3258{ 3226{
3259 struct rtnl_link_stats64 *cur_ns = &vsi->net_stats; 3227 struct rtnl_link_stats64 *cur_ns = &vsi->net_stats;
3260 struct ice_eth_stats *cur_es = &vsi->eth_stats; 3228 struct ice_eth_stats *cur_es = &vsi->eth_stats;
@@ -3290,7 +3258,7 @@ static void ice_update_vsi_stats(struct ice_vsi *vsi)
3290 * ice_update_pf_stats - Update PF port stats counters 3258 * ice_update_pf_stats - Update PF port stats counters
3291 * @pf: PF whose stats needs to be updated 3259 * @pf: PF whose stats needs to be updated
3292 */ 3260 */
3293static void ice_update_pf_stats(struct ice_pf *pf) 3261void ice_update_pf_stats(struct ice_pf *pf)
3294{ 3262{
3295 struct ice_hw_port_stats *prev_ps, *cur_ps; 3263 struct ice_hw_port_stats *prev_ps, *cur_ps;
3296 struct ice_hw *hw = &pf->hw; 3264 struct ice_hw *hw = &pf->hw;