| .. | .. |
|---|
| 1 | | -/* |
|---|
| 2 | | - * aQuantia Corporation Network Driver |
|---|
| 3 | | - * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 2 | +/* Atlantic Network Driver |
|---|
| 4 | 3 | * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 7 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 4 | + * Copyright (C) 2014-2019 aQuantia Corporation |
|---|
| 5 | + * Copyright (C) 2019-2020 Marvell International Ltd. |
|---|
| 8 | 6 | */ |
|---|
| 9 | 7 | |
|---|
| 10 | 8 | /* File aq_main.c: Main file for aQuantia Linux driver. */ |
|---|
| .. | .. |
|---|
| 13 | 11 | #include "aq_nic.h" |
|---|
| 14 | 12 | #include "aq_pci_func.h" |
|---|
| 15 | 13 | #include "aq_ethtool.h" |
|---|
| 14 | +#include "aq_ptp.h" |
|---|
| 15 | +#include "aq_filters.h" |
|---|
| 16 | +#include "aq_hw_utils.h" |
|---|
| 16 | 17 | |
|---|
| 17 | 18 | #include <linux/netdevice.h> |
|---|
| 18 | 19 | #include <linux/module.h> |
|---|
| 20 | +#include <linux/ip.h> |
|---|
| 21 | +#include <linux/udp.h> |
|---|
| 22 | +#include <net/pkt_cls.h> |
|---|
| 19 | 23 | |
|---|
| 20 | 24 | MODULE_LICENSE("GPL v2"); |
|---|
| 21 | | -MODULE_VERSION(AQ_CFG_DRV_VERSION); |
|---|
| 22 | 25 | MODULE_AUTHOR(AQ_CFG_DRV_AUTHOR); |
|---|
| 23 | 26 | MODULE_DESCRIPTION(AQ_CFG_DRV_DESC); |
|---|
| 24 | 27 | |
|---|
| 28 | +static const char aq_ndev_driver_name[] = AQ_CFG_DRV_NAME; |
|---|
| 29 | + |
|---|
| 25 | 30 | static const struct net_device_ops aq_ndev_ops; |
|---|
| 31 | + |
|---|
| 32 | +static struct workqueue_struct *aq_ndev_wq; |
|---|
| 33 | + |
|---|
| 34 | +void aq_ndev_schedule_work(struct work_struct *work) |
|---|
| 35 | +{ |
|---|
| 36 | + queue_work(aq_ndev_wq, work); |
|---|
| 37 | +} |
|---|
| 26 | 38 | |
|---|
| 27 | 39 | struct net_device *aq_ndev_alloc(void) |
|---|
| 28 | 40 | { |
|---|
| 29 | 41 | struct net_device *ndev = NULL; |
|---|
| 30 | 42 | struct aq_nic_s *aq_nic = NULL; |
|---|
| 31 | 43 | |
|---|
| 32 | | - ndev = alloc_etherdev_mq(sizeof(struct aq_nic_s), AQ_CFG_VECS_MAX); |
|---|
| 44 | + ndev = alloc_etherdev_mq(sizeof(struct aq_nic_s), AQ_HW_QUEUES_MAX); |
|---|
| 33 | 45 | if (!ndev) |
|---|
| 34 | 46 | return NULL; |
|---|
| 35 | 47 | |
|---|
| .. | .. |
|---|
| 41 | 53 | return ndev; |
|---|
| 42 | 54 | } |
|---|
| 43 | 55 | |
|---|
| 44 | | -static int aq_ndev_open(struct net_device *ndev) |
|---|
| 56 | +int aq_ndev_open(struct net_device *ndev) |
|---|
| 45 | 57 | { |
|---|
| 46 | | - int err = 0; |
|---|
| 47 | 58 | struct aq_nic_s *aq_nic = netdev_priv(ndev); |
|---|
| 59 | + int err = 0; |
|---|
| 48 | 60 | |
|---|
| 49 | 61 | err = aq_nic_init(aq_nic); |
|---|
| 50 | 62 | if (err < 0) |
|---|
| 51 | 63 | goto err_exit; |
|---|
| 64 | + |
|---|
| 65 | + err = aq_reapply_rxnfc_all_rules(aq_nic); |
|---|
| 66 | + if (err < 0) |
|---|
| 67 | + goto err_exit; |
|---|
| 68 | + |
|---|
| 69 | + err = aq_filters_vlans_update(aq_nic); |
|---|
| 70 | + if (err < 0) |
|---|
| 71 | + goto err_exit; |
|---|
| 72 | + |
|---|
| 52 | 73 | err = aq_nic_start(aq_nic); |
|---|
| 53 | 74 | if (err < 0) { |
|---|
| 54 | 75 | aq_nic_stop(aq_nic); |
|---|
| .. | .. |
|---|
| 57 | 78 | |
|---|
| 58 | 79 | err_exit: |
|---|
| 59 | 80 | if (err < 0) |
|---|
| 60 | | - aq_nic_deinit(aq_nic); |
|---|
| 81 | + aq_nic_deinit(aq_nic, true); |
|---|
| 82 | + |
|---|
| 61 | 83 | return err; |
|---|
| 62 | 84 | } |
|---|
| 63 | 85 | |
|---|
| 64 | | -static int aq_ndev_close(struct net_device *ndev) |
|---|
| 86 | +int aq_ndev_close(struct net_device *ndev) |
|---|
| 65 | 87 | { |
|---|
| 66 | | - int err = 0; |
|---|
| 67 | 88 | struct aq_nic_s *aq_nic = netdev_priv(ndev); |
|---|
| 89 | + int err = 0; |
|---|
| 68 | 90 | |
|---|
| 69 | 91 | err = aq_nic_stop(aq_nic); |
|---|
| 70 | | - if (err < 0) |
|---|
| 71 | | - goto err_exit; |
|---|
| 72 | | - aq_nic_deinit(aq_nic); |
|---|
| 92 | + aq_nic_deinit(aq_nic, true); |
|---|
| 73 | 93 | |
|---|
| 74 | | -err_exit: |
|---|
| 75 | 94 | return err; |
|---|
| 76 | 95 | } |
|---|
| 77 | 96 | |
|---|
| 78 | | -static int aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *ndev) |
|---|
| 97 | +static netdev_tx_t aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *ndev) |
|---|
| 79 | 98 | { |
|---|
| 80 | 99 | struct aq_nic_s *aq_nic = netdev_priv(ndev); |
|---|
| 81 | 100 | |
|---|
| 101 | +#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) |
|---|
| 102 | + if (unlikely(aq_utils_obj_test(&aq_nic->flags, AQ_NIC_PTP_DPATH_UP))) { |
|---|
| 103 | + /* Hardware adds the Timestamp for PTPv2 802.AS1 |
|---|
| 104 | + * and PTPv2 IPv4 UDP. |
|---|
| 105 | + * We have to push even general 320 port messages to the ptp |
|---|
| 106 | + * queue explicitly. This is a limitation of current firmware |
|---|
| 107 | + * and hardware PTP design of the chip. Otherwise ptp stream |
|---|
| 108 | + * will fail to sync |
|---|
| 109 | + */ |
|---|
| 110 | + if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) || |
|---|
| 111 | + unlikely((ip_hdr(skb)->version == 4) && |
|---|
| 112 | + (ip_hdr(skb)->protocol == IPPROTO_UDP) && |
|---|
| 113 | + ((udp_hdr(skb)->dest == htons(319)) || |
|---|
| 114 | + (udp_hdr(skb)->dest == htons(320)))) || |
|---|
| 115 | + unlikely(eth_hdr(skb)->h_proto == htons(ETH_P_1588))) |
|---|
| 116 | + return aq_ptp_xmit(aq_nic, skb); |
|---|
| 117 | + } |
|---|
| 118 | +#endif |
|---|
| 119 | + |
|---|
| 120 | + skb_tx_timestamp(skb); |
|---|
| 82 | 121 | return aq_nic_xmit(aq_nic, skb); |
|---|
| 83 | 122 | } |
|---|
| 84 | 123 | |
|---|
| 85 | 124 | static int aq_ndev_change_mtu(struct net_device *ndev, int new_mtu) |
|---|
| 86 | 125 | { |
|---|
| 87 | 126 | struct aq_nic_s *aq_nic = netdev_priv(ndev); |
|---|
| 88 | | - int err = aq_nic_set_mtu(aq_nic, new_mtu + ETH_HLEN); |
|---|
| 127 | + int err; |
|---|
| 128 | + |
|---|
| 129 | + err = aq_nic_set_mtu(aq_nic, new_mtu + ETH_HLEN); |
|---|
| 89 | 130 | |
|---|
| 90 | 131 | if (err < 0) |
|---|
| 91 | 132 | goto err_exit; |
|---|
| .. | .. |
|---|
| 98 | 139 | static int aq_ndev_set_features(struct net_device *ndev, |
|---|
| 99 | 140 | netdev_features_t features) |
|---|
| 100 | 141 | { |
|---|
| 142 | + bool is_vlan_tx_insert = !!(features & NETIF_F_HW_VLAN_CTAG_TX); |
|---|
| 143 | + bool is_vlan_rx_strip = !!(features & NETIF_F_HW_VLAN_CTAG_RX); |
|---|
| 101 | 144 | struct aq_nic_s *aq_nic = netdev_priv(ndev); |
|---|
| 102 | | - struct aq_nic_cfg_s *aq_cfg = aq_nic_get_cfg(aq_nic); |
|---|
| 145 | + bool need_ndev_restart = false; |
|---|
| 146 | + struct aq_nic_cfg_s *aq_cfg; |
|---|
| 103 | 147 | bool is_lro = false; |
|---|
| 148 | + int err = 0; |
|---|
| 104 | 149 | |
|---|
| 105 | | - if (aq_cfg->hw_features & NETIF_F_LRO) { |
|---|
| 150 | + aq_cfg = aq_nic_get_cfg(aq_nic); |
|---|
| 151 | + |
|---|
| 152 | + if (!(features & NETIF_F_NTUPLE)) { |
|---|
| 153 | + if (aq_nic->ndev->features & NETIF_F_NTUPLE) { |
|---|
| 154 | + err = aq_clear_rxnfc_all_rules(aq_nic); |
|---|
| 155 | + if (unlikely(err)) |
|---|
| 156 | + goto err_exit; |
|---|
| 157 | + } |
|---|
| 158 | + } |
|---|
| 159 | + if (!(features & NETIF_F_HW_VLAN_CTAG_FILTER)) { |
|---|
| 160 | + if (aq_nic->ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) { |
|---|
| 161 | + err = aq_filters_vlan_offload_off(aq_nic); |
|---|
| 162 | + if (unlikely(err)) |
|---|
| 163 | + goto err_exit; |
|---|
| 164 | + } |
|---|
| 165 | + } |
|---|
| 166 | + |
|---|
| 167 | + aq_cfg->features = features; |
|---|
| 168 | + |
|---|
| 169 | + if (aq_cfg->aq_hw_caps->hw_features & NETIF_F_LRO) { |
|---|
| 106 | 170 | is_lro = features & NETIF_F_LRO; |
|---|
| 107 | 171 | |
|---|
| 108 | 172 | if (aq_cfg->is_lro != is_lro) { |
|---|
| 109 | 173 | aq_cfg->is_lro = is_lro; |
|---|
| 110 | | - |
|---|
| 111 | | - if (netif_running(ndev)) { |
|---|
| 112 | | - aq_ndev_close(ndev); |
|---|
| 113 | | - aq_ndev_open(ndev); |
|---|
| 114 | | - } |
|---|
| 174 | + need_ndev_restart = true; |
|---|
| 115 | 175 | } |
|---|
| 116 | 176 | } |
|---|
| 117 | 177 | |
|---|
| 118 | | - return 0; |
|---|
| 178 | + if ((aq_nic->ndev->features ^ features) & NETIF_F_RXCSUM) { |
|---|
| 179 | + err = aq_nic->aq_hw_ops->hw_set_offload(aq_nic->aq_hw, |
|---|
| 180 | + aq_cfg); |
|---|
| 181 | + |
|---|
| 182 | + if (unlikely(err)) |
|---|
| 183 | + goto err_exit; |
|---|
| 184 | + } |
|---|
| 185 | + |
|---|
| 186 | + if (aq_cfg->is_vlan_rx_strip != is_vlan_rx_strip) { |
|---|
| 187 | + aq_cfg->is_vlan_rx_strip = is_vlan_rx_strip; |
|---|
| 188 | + need_ndev_restart = true; |
|---|
| 189 | + } |
|---|
| 190 | + if (aq_cfg->is_vlan_tx_insert != is_vlan_tx_insert) { |
|---|
| 191 | + aq_cfg->is_vlan_tx_insert = is_vlan_tx_insert; |
|---|
| 192 | + need_ndev_restart = true; |
|---|
| 193 | + } |
|---|
| 194 | + |
|---|
| 195 | + if (need_ndev_restart && netif_running(ndev)) { |
|---|
| 196 | + aq_ndev_close(ndev); |
|---|
| 197 | + aq_ndev_open(ndev); |
|---|
| 198 | + } |
|---|
| 199 | + |
|---|
| 200 | +err_exit: |
|---|
| 201 | + return err; |
|---|
| 119 | 202 | } |
|---|
| 120 | 203 | |
|---|
| 121 | 204 | static int aq_ndev_set_mac_address(struct net_device *ndev, void *addr) |
|---|
| .. | .. |
|---|
| 138 | 221 | { |
|---|
| 139 | 222 | struct aq_nic_s *aq_nic = netdev_priv(ndev); |
|---|
| 140 | 223 | |
|---|
| 141 | | - aq_nic_set_packet_filter(aq_nic, ndev->flags); |
|---|
| 224 | + (void)aq_nic_set_multicast_list(aq_nic, ndev); |
|---|
| 225 | +} |
|---|
| 142 | 226 | |
|---|
| 143 | | - aq_nic_set_multicast_list(aq_nic, ndev); |
|---|
| 227 | +#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) |
|---|
| 228 | +static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic, |
|---|
| 229 | + struct hwtstamp_config *config) |
|---|
| 230 | +{ |
|---|
| 231 | + if (config->flags) |
|---|
| 232 | + return -EINVAL; |
|---|
| 233 | + |
|---|
| 234 | + switch (config->tx_type) { |
|---|
| 235 | + case HWTSTAMP_TX_OFF: |
|---|
| 236 | + case HWTSTAMP_TX_ON: |
|---|
| 237 | + break; |
|---|
| 238 | + default: |
|---|
| 239 | + return -ERANGE; |
|---|
| 240 | + } |
|---|
| 241 | + |
|---|
| 242 | + switch (config->rx_filter) { |
|---|
| 243 | + case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: |
|---|
| 244 | + case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: |
|---|
| 245 | + case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: |
|---|
| 246 | + case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: |
|---|
| 247 | + case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: |
|---|
| 248 | + case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: |
|---|
| 249 | + case HWTSTAMP_FILTER_PTP_V2_SYNC: |
|---|
| 250 | + case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: |
|---|
| 251 | + config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; |
|---|
| 252 | + break; |
|---|
| 253 | + case HWTSTAMP_FILTER_PTP_V2_EVENT: |
|---|
| 254 | + case HWTSTAMP_FILTER_NONE: |
|---|
| 255 | + break; |
|---|
| 256 | + default: |
|---|
| 257 | + return -ERANGE; |
|---|
| 258 | + } |
|---|
| 259 | + |
|---|
| 260 | + return aq_ptp_hwtstamp_config_set(aq_nic->aq_ptp, config); |
|---|
| 261 | +} |
|---|
| 262 | +#endif |
|---|
| 263 | + |
|---|
| 264 | +static int aq_ndev_hwtstamp_set(struct aq_nic_s *aq_nic, struct ifreq *ifr) |
|---|
| 265 | +{ |
|---|
| 266 | + struct hwtstamp_config config; |
|---|
| 267 | +#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) |
|---|
| 268 | + int ret_val; |
|---|
| 269 | +#endif |
|---|
| 270 | + |
|---|
| 271 | + if (!aq_nic->aq_ptp) |
|---|
| 272 | + return -EOPNOTSUPP; |
|---|
| 273 | + |
|---|
| 274 | + if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) |
|---|
| 275 | + return -EFAULT; |
|---|
| 276 | +#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) |
|---|
| 277 | + ret_val = aq_ndev_config_hwtstamp(aq_nic, &config); |
|---|
| 278 | + if (ret_val) |
|---|
| 279 | + return ret_val; |
|---|
| 280 | +#endif |
|---|
| 281 | + |
|---|
| 282 | + return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? |
|---|
| 283 | + -EFAULT : 0; |
|---|
| 284 | +} |
|---|
| 285 | + |
|---|
| 286 | +#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) |
|---|
| 287 | +static int aq_ndev_hwtstamp_get(struct aq_nic_s *aq_nic, struct ifreq *ifr) |
|---|
| 288 | +{ |
|---|
| 289 | + struct hwtstamp_config config; |
|---|
| 290 | + |
|---|
| 291 | + if (!aq_nic->aq_ptp) |
|---|
| 292 | + return -EOPNOTSUPP; |
|---|
| 293 | + |
|---|
| 294 | + aq_ptp_hwtstamp_config_get(aq_nic->aq_ptp, &config); |
|---|
| 295 | + return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? |
|---|
| 296 | + -EFAULT : 0; |
|---|
| 297 | +} |
|---|
| 298 | +#endif |
|---|
| 299 | + |
|---|
| 300 | +static int aq_ndev_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) |
|---|
| 301 | +{ |
|---|
| 302 | + struct aq_nic_s *aq_nic = netdev_priv(netdev); |
|---|
| 303 | + |
|---|
| 304 | + switch (cmd) { |
|---|
| 305 | + case SIOCSHWTSTAMP: |
|---|
| 306 | + return aq_ndev_hwtstamp_set(aq_nic, ifr); |
|---|
| 307 | + |
|---|
| 308 | +#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) |
|---|
| 309 | + case SIOCGHWTSTAMP: |
|---|
| 310 | + return aq_ndev_hwtstamp_get(aq_nic, ifr); |
|---|
| 311 | +#endif |
|---|
| 312 | + } |
|---|
| 313 | + |
|---|
| 314 | + return -EOPNOTSUPP; |
|---|
| 315 | +} |
|---|
| 316 | + |
|---|
| 317 | +static int aq_ndo_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, |
|---|
| 318 | + u16 vid) |
|---|
| 319 | +{ |
|---|
| 320 | + struct aq_nic_s *aq_nic = netdev_priv(ndev); |
|---|
| 321 | + |
|---|
| 322 | + if (!aq_nic->aq_hw_ops->hw_filter_vlan_set) |
|---|
| 323 | + return -EOPNOTSUPP; |
|---|
| 324 | + |
|---|
| 325 | + set_bit(vid, aq_nic->active_vlans); |
|---|
| 326 | + |
|---|
| 327 | + return aq_filters_vlans_update(aq_nic); |
|---|
| 328 | +} |
|---|
| 329 | + |
|---|
| 330 | +static int aq_ndo_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, |
|---|
| 331 | + u16 vid) |
|---|
| 332 | +{ |
|---|
| 333 | + struct aq_nic_s *aq_nic = netdev_priv(ndev); |
|---|
| 334 | + |
|---|
| 335 | + if (!aq_nic->aq_hw_ops->hw_filter_vlan_set) |
|---|
| 336 | + return -EOPNOTSUPP; |
|---|
| 337 | + |
|---|
| 338 | + clear_bit(vid, aq_nic->active_vlans); |
|---|
| 339 | + |
|---|
| 340 | + if (-ENOENT == aq_del_fvlan_by_vlan(aq_nic, vid)) |
|---|
| 341 | + return aq_filters_vlans_update(aq_nic); |
|---|
| 342 | + |
|---|
| 343 | + return 0; |
|---|
| 344 | +} |
|---|
| 345 | + |
|---|
| 346 | +static int aq_validate_mqprio_opt(struct aq_nic_s *self, |
|---|
| 347 | + struct tc_mqprio_qopt_offload *mqprio, |
|---|
| 348 | + const unsigned int num_tc) |
|---|
| 349 | +{ |
|---|
| 350 | + const bool has_min_rate = !!(mqprio->flags & TC_MQPRIO_F_MIN_RATE); |
|---|
| 351 | + struct aq_nic_cfg_s *aq_nic_cfg = aq_nic_get_cfg(self); |
|---|
| 352 | + const unsigned int tcs_max = min_t(u8, aq_nic_cfg->aq_hw_caps->tcs_max, |
|---|
| 353 | + AQ_CFG_TCS_MAX); |
|---|
| 354 | + |
|---|
| 355 | + if (num_tc > tcs_max) { |
|---|
| 356 | + netdev_err(self->ndev, "Too many TCs requested\n"); |
|---|
| 357 | + return -EOPNOTSUPP; |
|---|
| 358 | + } |
|---|
| 359 | + |
|---|
| 360 | + if (num_tc != 0 && !is_power_of_2(num_tc)) { |
|---|
| 361 | + netdev_err(self->ndev, "TC count should be power of 2\n"); |
|---|
| 362 | + return -EOPNOTSUPP; |
|---|
| 363 | + } |
|---|
| 364 | + |
|---|
| 365 | + if (has_min_rate && !ATL_HW_IS_CHIP_FEATURE(self->aq_hw, ANTIGUA)) { |
|---|
| 366 | + netdev_err(self->ndev, "Min tx rate is not supported\n"); |
|---|
| 367 | + return -EOPNOTSUPP; |
|---|
| 368 | + } |
|---|
| 369 | + |
|---|
| 370 | + return 0; |
|---|
| 371 | +} |
|---|
| 372 | + |
|---|
| 373 | +static int aq_ndo_setup_tc(struct net_device *dev, enum tc_setup_type type, |
|---|
| 374 | + void *type_data) |
|---|
| 375 | +{ |
|---|
| 376 | + struct tc_mqprio_qopt_offload *mqprio = type_data; |
|---|
| 377 | + struct aq_nic_s *aq_nic = netdev_priv(dev); |
|---|
| 378 | + bool has_min_rate; |
|---|
| 379 | + bool has_max_rate; |
|---|
| 380 | + int err; |
|---|
| 381 | + int i; |
|---|
| 382 | + |
|---|
| 383 | + if (type != TC_SETUP_QDISC_MQPRIO) |
|---|
| 384 | + return -EOPNOTSUPP; |
|---|
| 385 | + |
|---|
| 386 | + has_min_rate = !!(mqprio->flags & TC_MQPRIO_F_MIN_RATE); |
|---|
| 387 | + has_max_rate = !!(mqprio->flags & TC_MQPRIO_F_MAX_RATE); |
|---|
| 388 | + |
|---|
| 389 | + err = aq_validate_mqprio_opt(aq_nic, mqprio, mqprio->qopt.num_tc); |
|---|
| 390 | + if (err) |
|---|
| 391 | + return err; |
|---|
| 392 | + |
|---|
| 393 | + for (i = 0; i < mqprio->qopt.num_tc; i++) { |
|---|
| 394 | + if (has_max_rate) { |
|---|
| 395 | + u64 max_rate = mqprio->max_rate[i]; |
|---|
| 396 | + |
|---|
| 397 | + do_div(max_rate, AQ_MBPS_DIVISOR); |
|---|
| 398 | + aq_nic_setup_tc_max_rate(aq_nic, i, (u32)max_rate); |
|---|
| 399 | + } |
|---|
| 400 | + |
|---|
| 401 | + if (has_min_rate) { |
|---|
| 402 | + u64 min_rate = mqprio->min_rate[i]; |
|---|
| 403 | + |
|---|
| 404 | + do_div(min_rate, AQ_MBPS_DIVISOR); |
|---|
| 405 | + aq_nic_setup_tc_min_rate(aq_nic, i, (u32)min_rate); |
|---|
| 406 | + } |
|---|
| 407 | + } |
|---|
| 408 | + |
|---|
| 409 | + return aq_nic_setup_tc_mqprio(aq_nic, mqprio->qopt.num_tc, |
|---|
| 410 | + mqprio->qopt.prio_tc_map); |
|---|
| 144 | 411 | } |
|---|
| 145 | 412 | |
|---|
| 146 | 413 | static const struct net_device_ops aq_ndev_ops = { |
|---|
| .. | .. |
|---|
| 150 | 417 | .ndo_set_rx_mode = aq_ndev_set_multicast_settings, |
|---|
| 151 | 418 | .ndo_change_mtu = aq_ndev_change_mtu, |
|---|
| 152 | 419 | .ndo_set_mac_address = aq_ndev_set_mac_address, |
|---|
| 153 | | - .ndo_set_features = aq_ndev_set_features |
|---|
| 420 | + .ndo_set_features = aq_ndev_set_features, |
|---|
| 421 | + .ndo_do_ioctl = aq_ndev_ioctl, |
|---|
| 422 | + .ndo_vlan_rx_add_vid = aq_ndo_vlan_rx_add_vid, |
|---|
| 423 | + .ndo_vlan_rx_kill_vid = aq_ndo_vlan_rx_kill_vid, |
|---|
| 424 | + .ndo_setup_tc = aq_ndo_setup_tc, |
|---|
| 154 | 425 | }; |
|---|
| 426 | + |
|---|
| 427 | +static int __init aq_ndev_init_module(void) |
|---|
| 428 | +{ |
|---|
| 429 | + int ret; |
|---|
| 430 | + |
|---|
| 431 | + aq_ndev_wq = create_singlethread_workqueue(aq_ndev_driver_name); |
|---|
| 432 | + if (!aq_ndev_wq) { |
|---|
| 433 | + pr_err("Failed to create workqueue\n"); |
|---|
| 434 | + return -ENOMEM; |
|---|
| 435 | + } |
|---|
| 436 | + |
|---|
| 437 | + ret = aq_pci_func_register_driver(); |
|---|
| 438 | + if (ret) { |
|---|
| 439 | + destroy_workqueue(aq_ndev_wq); |
|---|
| 440 | + return ret; |
|---|
| 441 | + } |
|---|
| 442 | + |
|---|
| 443 | + return 0; |
|---|
| 444 | +} |
|---|
| 445 | + |
|---|
| 446 | +static void __exit aq_ndev_exit_module(void) |
|---|
| 447 | +{ |
|---|
| 448 | + aq_pci_func_unregister_driver(); |
|---|
| 449 | + |
|---|
| 450 | + if (aq_ndev_wq) { |
|---|
| 451 | + destroy_workqueue(aq_ndev_wq); |
|---|
| 452 | + aq_ndev_wq = NULL; |
|---|
| 453 | + } |
|---|
| 454 | +} |
|---|
| 455 | + |
|---|
| 456 | +module_init(aq_ndev_init_module); |
|---|
| 457 | +module_exit(aq_ndev_exit_module); |
|---|