2 * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #include <generated/utsrelease.h>
34 #include <linux/mlx5/fs.h>
35 #include <net/switchdev.h>
36 #include <net/pkt_cls.h>
37 #include <net/act_api.h>
38 #include <net/devlink.h>
39 #include <net/ipv6_stubs.h>
42 #include "esw/chains.h"
47 #include "en/rep/tc.h"
48 #include "en/rep/neigh.h"
51 #define CREATE_TRACE_POINTS
52 #include "diag/en_rep_tracepoint.h"
54 #define MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE \
55 max(0x7, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)
56 #define MLX5E_REP_PARAMS_DEF_NUM_CHANNELS 1
58 static const char mlx5e_rep_driver_name[] = "mlx5e_rep";
60 static void mlx5e_rep_get_drvinfo(struct net_device *dev,
61 struct ethtool_drvinfo *drvinfo)
63 struct mlx5e_priv *priv = netdev_priv(dev);
64 struct mlx5_core_dev *mdev = priv->mdev;
66 strlcpy(drvinfo->driver, mlx5e_rep_driver_name,
67 sizeof(drvinfo->driver));
68 strlcpy(drvinfo->version, UTS_RELEASE, sizeof(drvinfo->version));
69 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
71 fw_rev_maj(mdev), fw_rev_min(mdev),
72 fw_rev_sub(mdev), mdev->board_id);
75 static void mlx5e_uplink_rep_get_drvinfo(struct net_device *dev,
76 struct ethtool_drvinfo *drvinfo)
78 struct mlx5e_priv *priv = netdev_priv(dev);
80 mlx5e_rep_get_drvinfo(dev, drvinfo);
81 strlcpy(drvinfo->bus_info, pci_name(priv->mdev->pdev),
82 sizeof(drvinfo->bus_info));
85 static const struct counter_desc sw_rep_stats_desc[] = {
86 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_packets) },
87 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_bytes) },
88 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_packets) },
89 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_bytes) },
99 static const struct counter_desc vport_rep_stats_desc[] = {
100 { MLX5E_DECLARE_STAT(struct vport_stats, vport_rx_packets) },
101 { MLX5E_DECLARE_STAT(struct vport_stats, vport_rx_bytes) },
102 { MLX5E_DECLARE_STAT(struct vport_stats, vport_tx_packets) },
103 { MLX5E_DECLARE_STAT(struct vport_stats, vport_tx_bytes) },
106 #define NUM_VPORT_REP_SW_COUNTERS ARRAY_SIZE(sw_rep_stats_desc)
107 #define NUM_VPORT_REP_HW_COUNTERS ARRAY_SIZE(vport_rep_stats_desc)
109 static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(sw_rep)
111 return NUM_VPORT_REP_SW_COUNTERS;
114 static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(sw_rep)
118 for (i = 0; i < NUM_VPORT_REP_SW_COUNTERS; i++)
119 strcpy(data + (idx++) * ETH_GSTRING_LEN,
120 sw_rep_stats_desc[i].format);
124 static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(sw_rep)
128 for (i = 0; i < NUM_VPORT_REP_SW_COUNTERS; i++)
129 data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.sw,
130 sw_rep_stats_desc, i);
134 static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw_rep)
136 struct mlx5e_sw_stats *s = &priv->stats.sw;
137 struct rtnl_link_stats64 stats64 = {};
139 memset(s, 0, sizeof(*s));
140 mlx5e_fold_sw_stats64(priv, &stats64);
142 s->rx_packets = stats64.rx_packets;
143 s->rx_bytes = stats64.rx_bytes;
144 s->tx_packets = stats64.tx_packets;
145 s->tx_bytes = stats64.tx_bytes;
146 s->tx_queue_dropped = stats64.tx_dropped;
149 static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(vport_rep)
151 return NUM_VPORT_REP_HW_COUNTERS;
154 static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep)
158 for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++)
159 strcpy(data + (idx++) * ETH_GSTRING_LEN, vport_rep_stats_desc[i].format);
163 static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vport_rep)
167 for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++)
168 data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.vf_vport,
169 vport_rep_stats_desc, i);
173 static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(vport_rep)
175 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
176 struct mlx5e_rep_priv *rpriv = priv->ppriv;
177 struct mlx5_eswitch_rep *rep = rpriv->rep;
178 struct rtnl_link_stats64 *vport_stats;
179 struct ifla_vf_stats vf_stats;
182 err = mlx5_eswitch_get_vport_stats(esw, rep->vport, &vf_stats);
184 netdev_warn(priv->netdev, "vport %d error %d reading stats\n",
189 vport_stats = &priv->stats.vf_vport;
190 /* flip tx/rx as we are reporting the counters for the switch vport */
191 vport_stats->rx_packets = vf_stats.tx_packets;
192 vport_stats->rx_bytes = vf_stats.tx_bytes;
193 vport_stats->tx_packets = vf_stats.rx_packets;
194 vport_stats->tx_bytes = vf_stats.rx_bytes;
197 static void mlx5e_rep_get_strings(struct net_device *dev,
198 u32 stringset, uint8_t *data)
200 struct mlx5e_priv *priv = netdev_priv(dev);
204 mlx5e_stats_fill_strings(priv, data);
209 static void mlx5e_rep_get_ethtool_stats(struct net_device *dev,
210 struct ethtool_stats *stats, u64 *data)
212 struct mlx5e_priv *priv = netdev_priv(dev);
214 mlx5e_ethtool_get_ethtool_stats(priv, stats, data);
217 static int mlx5e_rep_get_sset_count(struct net_device *dev, int sset)
219 struct mlx5e_priv *priv = netdev_priv(dev);
223 return mlx5e_stats_total_num(priv);
229 static void mlx5e_rep_get_ringparam(struct net_device *dev,
230 struct ethtool_ringparam *param)
232 struct mlx5e_priv *priv = netdev_priv(dev);
234 mlx5e_ethtool_get_ringparam(priv, param);
237 static int mlx5e_rep_set_ringparam(struct net_device *dev,
238 struct ethtool_ringparam *param)
240 struct mlx5e_priv *priv = netdev_priv(dev);
242 return mlx5e_ethtool_set_ringparam(priv, param);
245 static void mlx5e_rep_get_channels(struct net_device *dev,
246 struct ethtool_channels *ch)
248 struct mlx5e_priv *priv = netdev_priv(dev);
250 mlx5e_ethtool_get_channels(priv, ch);
253 static int mlx5e_rep_set_channels(struct net_device *dev,
254 struct ethtool_channels *ch)
256 struct mlx5e_priv *priv = netdev_priv(dev);
258 return mlx5e_ethtool_set_channels(priv, ch);
261 static int mlx5e_rep_get_coalesce(struct net_device *netdev,
262 struct ethtool_coalesce *coal)
264 struct mlx5e_priv *priv = netdev_priv(netdev);
266 return mlx5e_ethtool_get_coalesce(priv, coal);
269 static int mlx5e_rep_set_coalesce(struct net_device *netdev,
270 struct ethtool_coalesce *coal)
272 struct mlx5e_priv *priv = netdev_priv(netdev);
274 return mlx5e_ethtool_set_coalesce(priv, coal);
277 static u32 mlx5e_rep_get_rxfh_key_size(struct net_device *netdev)
279 struct mlx5e_priv *priv = netdev_priv(netdev);
281 return mlx5e_ethtool_get_rxfh_key_size(priv);
284 static u32 mlx5e_rep_get_rxfh_indir_size(struct net_device *netdev)
286 struct mlx5e_priv *priv = netdev_priv(netdev);
288 return mlx5e_ethtool_get_rxfh_indir_size(priv);
291 static void mlx5e_uplink_rep_get_pauseparam(struct net_device *netdev,
292 struct ethtool_pauseparam *pauseparam)
294 struct mlx5e_priv *priv = netdev_priv(netdev);
296 mlx5e_ethtool_get_pauseparam(priv, pauseparam);
299 static int mlx5e_uplink_rep_set_pauseparam(struct net_device *netdev,
300 struct ethtool_pauseparam *pauseparam)
302 struct mlx5e_priv *priv = netdev_priv(netdev);
304 return mlx5e_ethtool_set_pauseparam(priv, pauseparam);
307 static int mlx5e_uplink_rep_get_link_ksettings(struct net_device *netdev,
308 struct ethtool_link_ksettings *link_ksettings)
310 struct mlx5e_priv *priv = netdev_priv(netdev);
312 return mlx5e_ethtool_get_link_ksettings(priv, link_ksettings);
315 static int mlx5e_uplink_rep_set_link_ksettings(struct net_device *netdev,
316 const struct ethtool_link_ksettings *link_ksettings)
318 struct mlx5e_priv *priv = netdev_priv(netdev);
320 return mlx5e_ethtool_set_link_ksettings(priv, link_ksettings);
323 static const struct ethtool_ops mlx5e_rep_ethtool_ops = {
324 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
325 ETHTOOL_COALESCE_MAX_FRAMES |
326 ETHTOOL_COALESCE_USE_ADAPTIVE,
327 .get_drvinfo = mlx5e_rep_get_drvinfo,
328 .get_link = ethtool_op_get_link,
329 .get_strings = mlx5e_rep_get_strings,
330 .get_sset_count = mlx5e_rep_get_sset_count,
331 .get_ethtool_stats = mlx5e_rep_get_ethtool_stats,
332 .get_ringparam = mlx5e_rep_get_ringparam,
333 .set_ringparam = mlx5e_rep_set_ringparam,
334 .get_channels = mlx5e_rep_get_channels,
335 .set_channels = mlx5e_rep_set_channels,
336 .get_coalesce = mlx5e_rep_get_coalesce,
337 .set_coalesce = mlx5e_rep_set_coalesce,
338 .get_rxfh_key_size = mlx5e_rep_get_rxfh_key_size,
339 .get_rxfh_indir_size = mlx5e_rep_get_rxfh_indir_size,
342 static const struct ethtool_ops mlx5e_uplink_rep_ethtool_ops = {
343 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
344 ETHTOOL_COALESCE_MAX_FRAMES |
345 ETHTOOL_COALESCE_USE_ADAPTIVE,
346 .get_drvinfo = mlx5e_uplink_rep_get_drvinfo,
347 .get_link = ethtool_op_get_link,
348 .get_strings = mlx5e_rep_get_strings,
349 .get_sset_count = mlx5e_rep_get_sset_count,
350 .get_ethtool_stats = mlx5e_rep_get_ethtool_stats,
351 .get_ringparam = mlx5e_rep_get_ringparam,
352 .set_ringparam = mlx5e_rep_set_ringparam,
353 .get_channels = mlx5e_rep_get_channels,
354 .set_channels = mlx5e_rep_set_channels,
355 .get_coalesce = mlx5e_rep_get_coalesce,
356 .set_coalesce = mlx5e_rep_set_coalesce,
357 .get_link_ksettings = mlx5e_uplink_rep_get_link_ksettings,
358 .set_link_ksettings = mlx5e_uplink_rep_set_link_ksettings,
359 .get_rxfh_key_size = mlx5e_rep_get_rxfh_key_size,
360 .get_rxfh_indir_size = mlx5e_rep_get_rxfh_indir_size,
361 .get_rxfh = mlx5e_get_rxfh,
362 .set_rxfh = mlx5e_set_rxfh,
363 .get_rxnfc = mlx5e_get_rxnfc,
364 .set_rxnfc = mlx5e_set_rxnfc,
365 .get_pauseparam = mlx5e_uplink_rep_get_pauseparam,
366 .set_pauseparam = mlx5e_uplink_rep_set_pauseparam,
369 static void mlx5e_rep_get_port_parent_id(struct net_device *dev,
370 struct netdev_phys_item_id *ppid)
372 struct mlx5e_priv *priv;
375 priv = netdev_priv(dev);
377 parent_id = mlx5_query_nic_system_image_guid(priv->mdev);
378 ppid->id_len = sizeof(parent_id);
379 memcpy(ppid->id, &parent_id, sizeof(parent_id));
382 static void mlx5e_sqs2vport_stop(struct mlx5_eswitch *esw,
383 struct mlx5_eswitch_rep *rep)
385 struct mlx5e_rep_sq *rep_sq, *tmp;
386 struct mlx5e_rep_priv *rpriv;
388 if (esw->mode != MLX5_ESWITCH_OFFLOADS)
391 rpriv = mlx5e_rep_to_rep_priv(rep);
392 list_for_each_entry_safe(rep_sq, tmp, &rpriv->vport_sqs_list, list) {
393 mlx5_eswitch_del_send_to_vport_rule(rep_sq->send_to_vport_rule);
394 list_del(&rep_sq->list);
399 static int mlx5e_sqs2vport_start(struct mlx5_eswitch *esw,
400 struct mlx5_eswitch_rep *rep,
401 u32 *sqns_array, int sqns_num)
403 struct mlx5_flow_handle *flow_rule;
404 struct mlx5e_rep_priv *rpriv;
405 struct mlx5e_rep_sq *rep_sq;
409 if (esw->mode != MLX5_ESWITCH_OFFLOADS)
412 rpriv = mlx5e_rep_to_rep_priv(rep);
413 for (i = 0; i < sqns_num; i++) {
414 rep_sq = kzalloc(sizeof(*rep_sq), GFP_KERNEL);
420 /* Add re-inject rule to the PF/representor sqs */
421 flow_rule = mlx5_eswitch_add_send_to_vport_rule(esw,
424 if (IS_ERR(flow_rule)) {
425 err = PTR_ERR(flow_rule);
429 rep_sq->send_to_vport_rule = flow_rule;
430 list_add(&rep_sq->list, &rpriv->vport_sqs_list);
435 mlx5e_sqs2vport_stop(esw, rep);
439 int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
441 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
442 struct mlx5e_rep_priv *rpriv = priv->ppriv;
443 struct mlx5_eswitch_rep *rep = rpriv->rep;
444 struct mlx5e_channel *c;
445 int n, tc, num_sqs = 0;
449 sqs = kcalloc(priv->channels.num * priv->channels.params.num_tc, sizeof(*sqs), GFP_KERNEL);
453 for (n = 0; n < priv->channels.num; n++) {
454 c = priv->channels.c[n];
455 for (tc = 0; tc < c->num_tc; tc++)
456 sqs[num_sqs++] = c->sq[tc].sqn;
459 err = mlx5e_sqs2vport_start(esw, rep, sqs, num_sqs);
464 netdev_warn(priv->netdev, "Failed to add SQs FWD rules %d\n", err);
468 void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv)
470 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
471 struct mlx5e_rep_priv *rpriv = priv->ppriv;
472 struct mlx5_eswitch_rep *rep = rpriv->rep;
474 mlx5e_sqs2vport_stop(esw, rep);
477 static int mlx5e_rep_open(struct net_device *dev)
479 struct mlx5e_priv *priv = netdev_priv(dev);
480 struct mlx5e_rep_priv *rpriv = priv->ppriv;
481 struct mlx5_eswitch_rep *rep = rpriv->rep;
484 mutex_lock(&priv->state_lock);
485 err = mlx5e_open_locked(dev);
489 if (!mlx5_modify_vport_admin_state(priv->mdev,
490 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
492 MLX5_VPORT_ADMIN_STATE_UP))
493 netif_carrier_on(dev);
496 mutex_unlock(&priv->state_lock);
500 static int mlx5e_rep_close(struct net_device *dev)
502 struct mlx5e_priv *priv = netdev_priv(dev);
503 struct mlx5e_rep_priv *rpriv = priv->ppriv;
504 struct mlx5_eswitch_rep *rep = rpriv->rep;
507 mutex_lock(&priv->state_lock);
508 mlx5_modify_vport_admin_state(priv->mdev,
509 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
511 MLX5_VPORT_ADMIN_STATE_DOWN);
512 ret = mlx5e_close_locked(dev);
513 mutex_unlock(&priv->state_lock);
517 bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
519 struct mlx5e_rep_priv *rpriv = priv->ppriv;
520 struct mlx5_eswitch_rep *rep;
522 if (!MLX5_ESWITCH_MANAGER(priv->mdev))
525 if (!rpriv) /* non vport rep mlx5e instances don't use this field */
529 return (rep->vport == MLX5_VPORT_UPLINK);
532 static bool mlx5e_rep_has_offload_stats(const struct net_device *dev, int attr_id)
535 case IFLA_OFFLOAD_XSTATS_CPU_HIT:
543 mlx5e_get_sw_stats64(const struct net_device *dev,
544 struct rtnl_link_stats64 *stats)
546 struct mlx5e_priv *priv = netdev_priv(dev);
548 mlx5e_fold_sw_stats64(priv, stats);
552 static int mlx5e_rep_get_offload_stats(int attr_id, const struct net_device *dev,
556 case IFLA_OFFLOAD_XSTATS_CPU_HIT:
557 return mlx5e_get_sw_stats64(dev, sp);
564 mlx5e_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
566 struct mlx5e_priv *priv = netdev_priv(dev);
568 /* update HW stats in background for next time */
569 mlx5e_queue_update_stats(priv);
570 memcpy(stats, &priv->stats.vf_vport, sizeof(*stats));
573 static int mlx5e_rep_change_mtu(struct net_device *netdev, int new_mtu)
575 return mlx5e_change_mtu(netdev, new_mtu, NULL);
578 static int mlx5e_uplink_rep_change_mtu(struct net_device *netdev, int new_mtu)
580 return mlx5e_change_mtu(netdev, new_mtu, mlx5e_set_dev_port_mtu_ctx);
583 static int mlx5e_uplink_rep_set_mac(struct net_device *netdev, void *addr)
585 struct sockaddr *saddr = addr;
587 if (!is_valid_ether_addr(saddr->sa_data))
588 return -EADDRNOTAVAIL;
590 ether_addr_copy(netdev->dev_addr, saddr->sa_data);
594 static int mlx5e_uplink_rep_set_vf_vlan(struct net_device *dev, int vf, u16 vlan, u8 qos,
597 netdev_warn_once(dev, "legacy vf vlan setting isn't supported in switchdev mode\n");
602 /* allow setting 0-vid for compatibility with libvirt */
606 static struct devlink_port *mlx5e_rep_get_devlink_port(struct net_device *dev)
608 struct mlx5e_priv *priv = netdev_priv(dev);
609 struct mlx5e_rep_priv *rpriv = priv->ppriv;
611 return &rpriv->dl_port;
614 static const struct net_device_ops mlx5e_netdev_ops_rep = {
615 .ndo_open = mlx5e_rep_open,
616 .ndo_stop = mlx5e_rep_close,
617 .ndo_start_xmit = mlx5e_xmit,
618 .ndo_setup_tc = mlx5e_rep_setup_tc,
619 .ndo_get_devlink_port = mlx5e_rep_get_devlink_port,
620 .ndo_get_stats64 = mlx5e_rep_get_stats,
621 .ndo_has_offload_stats = mlx5e_rep_has_offload_stats,
622 .ndo_get_offload_stats = mlx5e_rep_get_offload_stats,
623 .ndo_change_mtu = mlx5e_rep_change_mtu,
626 static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = {
627 .ndo_open = mlx5e_open,
628 .ndo_stop = mlx5e_close,
629 .ndo_start_xmit = mlx5e_xmit,
630 .ndo_set_mac_address = mlx5e_uplink_rep_set_mac,
631 .ndo_setup_tc = mlx5e_rep_setup_tc,
632 .ndo_get_devlink_port = mlx5e_rep_get_devlink_port,
633 .ndo_get_stats64 = mlx5e_get_stats,
634 .ndo_has_offload_stats = mlx5e_rep_has_offload_stats,
635 .ndo_get_offload_stats = mlx5e_rep_get_offload_stats,
636 .ndo_change_mtu = mlx5e_uplink_rep_change_mtu,
637 .ndo_udp_tunnel_add = mlx5e_add_vxlan_port,
638 .ndo_udp_tunnel_del = mlx5e_del_vxlan_port,
639 .ndo_features_check = mlx5e_features_check,
640 .ndo_set_vf_mac = mlx5e_set_vf_mac,
641 .ndo_set_vf_rate = mlx5e_set_vf_rate,
642 .ndo_get_vf_config = mlx5e_get_vf_config,
643 .ndo_get_vf_stats = mlx5e_get_vf_stats,
644 .ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan,
645 .ndo_set_features = mlx5e_set_features,
648 bool mlx5e_eswitch_uplink_rep(struct net_device *netdev)
650 return netdev->netdev_ops == &mlx5e_netdev_ops_uplink_rep;
653 bool mlx5e_eswitch_vf_rep(struct net_device *netdev)
655 return netdev->netdev_ops == &mlx5e_netdev_ops_rep;
658 static void mlx5e_build_rep_params(struct net_device *netdev)
660 struct mlx5e_priv *priv = netdev_priv(netdev);
661 struct mlx5e_rep_priv *rpriv = priv->ppriv;
662 struct mlx5_eswitch_rep *rep = rpriv->rep;
663 struct mlx5_core_dev *mdev = priv->mdev;
664 struct mlx5e_params *params;
666 u8 cq_period_mode = MLX5_CAP_GEN(mdev, cq_period_start_from_cqe) ?
667 MLX5_CQ_PERIOD_MODE_START_FROM_CQE :
668 MLX5_CQ_PERIOD_MODE_START_FROM_EQE;
670 params = &priv->channels.params;
671 params->hard_mtu = MLX5E_ETH_HARD_MTU;
672 params->sw_mtu = netdev->mtu;
675 if (rep->vport == MLX5_VPORT_UPLINK)
676 params->log_sq_size = MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
678 params->log_sq_size = MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE;
681 mlx5e_build_rq_params(mdev, params);
683 /* CQ moderation params */
684 params->rx_dim_enabled = MLX5_CAP_GEN(mdev, cq_moderation);
685 mlx5e_set_rx_cq_mode_params(params, cq_period_mode);
688 params->tunneled_offload_en = false;
690 mlx5_query_min_inline(mdev, ¶ms->tx_min_inline_mode);
693 mlx5e_build_rss_params(&priv->rss_params, params->num_channels);
696 static void mlx5e_build_rep_netdev(struct net_device *netdev)
698 struct mlx5e_priv *priv = netdev_priv(netdev);
699 struct mlx5e_rep_priv *rpriv = priv->ppriv;
700 struct mlx5_eswitch_rep *rep = rpriv->rep;
701 struct mlx5_core_dev *mdev = priv->mdev;
703 SET_NETDEV_DEV(netdev, mdev->device);
704 if (rep->vport == MLX5_VPORT_UPLINK) {
705 netdev->netdev_ops = &mlx5e_netdev_ops_uplink_rep;
706 /* we want a persistent mac for the uplink rep */
707 mlx5_query_mac_address(mdev, netdev->dev_addr);
708 netdev->ethtool_ops = &mlx5e_uplink_rep_ethtool_ops;
709 mlx5e_dcbnl_build_rep_netdev(netdev);
711 netdev->netdev_ops = &mlx5e_netdev_ops_rep;
712 eth_hw_addr_random(netdev);
713 netdev->ethtool_ops = &mlx5e_rep_ethtool_ops;
716 netdev->watchdog_timeo = 15 * HZ;
718 netdev->features |= NETIF_F_NETNS_LOCAL;
720 netdev->hw_features |= NETIF_F_HW_TC;
721 netdev->hw_features |= NETIF_F_SG;
722 netdev->hw_features |= NETIF_F_IP_CSUM;
723 netdev->hw_features |= NETIF_F_IPV6_CSUM;
724 netdev->hw_features |= NETIF_F_GRO;
725 netdev->hw_features |= NETIF_F_TSO;
726 netdev->hw_features |= NETIF_F_TSO6;
727 netdev->hw_features |= NETIF_F_RXCSUM;
729 if (rep->vport == MLX5_VPORT_UPLINK)
730 netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX;
732 netdev->features |= NETIF_F_VLAN_CHALLENGED;
734 netdev->features |= netdev->hw_features;
737 static int mlx5e_init_rep(struct mlx5_core_dev *mdev,
738 struct net_device *netdev,
739 const struct mlx5e_profile *profile,
742 struct mlx5e_priv *priv = netdev_priv(netdev);
745 err = mlx5e_netdev_init(netdev, priv, mdev, profile, ppriv);
749 priv->channels.params.num_channels = MLX5E_REP_PARAMS_DEF_NUM_CHANNELS;
751 mlx5e_build_rep_params(netdev);
752 mlx5e_build_rep_netdev(netdev);
754 mlx5e_timestamp_init(priv);
759 static void mlx5e_cleanup_rep(struct mlx5e_priv *priv)
761 mlx5e_netdev_cleanup(priv->netdev, priv);
764 static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)
766 struct mlx5e_rep_priv *rpriv = priv->ppriv;
767 struct mlx5_eswitch_rep *rep = rpriv->rep;
768 struct ttc_params ttc_params = {};
771 priv->fs.ns = mlx5_get_flow_namespace(priv->mdev,
772 MLX5_FLOW_NAMESPACE_KERNEL);
774 /* The inner_ttc in the ttc params is intentionally not set */
775 ttc_params.any_tt_tirn = priv->direct_tir[0].tirn;
776 mlx5e_set_ttc_ft_params(&ttc_params);
778 if (rep->vport != MLX5_VPORT_UPLINK)
779 /* To give uplik rep TTC a lower level for chaining from root ft */
780 ttc_params.ft_attr.level = MLX5E_TTC_FT_LEVEL + 1;
782 for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
783 ttc_params.indir_tirn[tt] = priv->indir_tir[tt].tirn;
785 err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc);
787 netdev_err(priv->netdev, "Failed to create rep ttc table, err=%d\n", err);
793 static int mlx5e_create_rep_root_ft(struct mlx5e_priv *priv)
795 struct mlx5e_rep_priv *rpriv = priv->ppriv;
796 struct mlx5_eswitch_rep *rep = rpriv->rep;
797 struct mlx5_flow_table_attr ft_attr = {};
798 struct mlx5_flow_namespace *ns;
801 if (rep->vport != MLX5_VPORT_UPLINK) {
802 /* non uplik reps will skip any bypass tables and go directly to
805 rpriv->root_ft = priv->fs.ttc.ft.t;
809 /* uplink root ft will be used to auto chain, to ethtool or ttc tables */
810 ns = mlx5_get_flow_namespace(priv->mdev, MLX5_FLOW_NAMESPACE_OFFLOADS);
812 netdev_err(priv->netdev, "Failed to get reps offloads namespace\n");
816 ft_attr.max_fte = 0; /* Empty table, miss rule will always point to next table */
820 rpriv->root_ft = mlx5_create_flow_table(ns, &ft_attr);
821 if (IS_ERR(rpriv->root_ft)) {
822 err = PTR_ERR(rpriv->root_ft);
823 rpriv->root_ft = NULL;
829 static void mlx5e_destroy_rep_root_ft(struct mlx5e_priv *priv)
831 struct mlx5e_rep_priv *rpriv = priv->ppriv;
832 struct mlx5_eswitch_rep *rep = rpriv->rep;
834 if (rep->vport != MLX5_VPORT_UPLINK)
836 mlx5_destroy_flow_table(rpriv->root_ft);
839 static int mlx5e_create_rep_vport_rx_rule(struct mlx5e_priv *priv)
841 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
842 struct mlx5e_rep_priv *rpriv = priv->ppriv;
843 struct mlx5_eswitch_rep *rep = rpriv->rep;
844 struct mlx5_flow_handle *flow_rule;
845 struct mlx5_flow_destination dest;
847 dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
848 dest.ft = rpriv->root_ft;
850 flow_rule = mlx5_eswitch_create_vport_rx_rule(esw, rep->vport, &dest);
851 if (IS_ERR(flow_rule))
852 return PTR_ERR(flow_rule);
853 rpriv->vport_rx_rule = flow_rule;
857 static void rep_vport_rx_rule_destroy(struct mlx5e_priv *priv)
859 struct mlx5e_rep_priv *rpriv = priv->ppriv;
861 if (!rpriv->vport_rx_rule)
864 mlx5_del_flow_rules(rpriv->vport_rx_rule);
865 rpriv->vport_rx_rule = NULL;
868 int mlx5e_rep_bond_update(struct mlx5e_priv *priv, bool cleanup)
870 rep_vport_rx_rule_destroy(priv);
872 return cleanup ? 0 : mlx5e_create_rep_vport_rx_rule(priv);
875 static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
877 struct mlx5_core_dev *mdev = priv->mdev;
880 mlx5e_init_l2_addr(priv);
882 err = mlx5e_open_drop_rq(priv, &priv->drop_rq);
884 mlx5_core_err(mdev, "open drop rq failed, %d\n", err);
888 err = mlx5e_create_indirect_rqt(priv);
890 goto err_close_drop_rq;
892 err = mlx5e_create_direct_rqts(priv, priv->direct_tir);
894 goto err_destroy_indirect_rqts;
896 err = mlx5e_create_indirect_tirs(priv, false);
898 goto err_destroy_direct_rqts;
900 err = mlx5e_create_direct_tirs(priv, priv->direct_tir);
902 goto err_destroy_indirect_tirs;
904 err = mlx5e_create_rep_ttc_table(priv);
906 goto err_destroy_direct_tirs;
908 err = mlx5e_create_rep_root_ft(priv);
910 goto err_destroy_ttc_table;
912 err = mlx5e_create_rep_vport_rx_rule(priv);
914 goto err_destroy_root_ft;
916 mlx5e_ethtool_init_steering(priv);
921 mlx5e_destroy_rep_root_ft(priv);
922 err_destroy_ttc_table:
923 mlx5e_destroy_ttc_table(priv, &priv->fs.ttc);
924 err_destroy_direct_tirs:
925 mlx5e_destroy_direct_tirs(priv, priv->direct_tir);
926 err_destroy_indirect_tirs:
927 mlx5e_destroy_indirect_tirs(priv);
928 err_destroy_direct_rqts:
929 mlx5e_destroy_direct_rqts(priv, priv->direct_tir);
930 err_destroy_indirect_rqts:
931 mlx5e_destroy_rqt(priv, &priv->indir_rqt);
933 mlx5e_close_drop_rq(&priv->drop_rq);
937 static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
939 rep_vport_rx_rule_destroy(priv);
940 mlx5e_destroy_rep_root_ft(priv);
941 mlx5e_destroy_ttc_table(priv, &priv->fs.ttc);
942 mlx5e_destroy_direct_tirs(priv, priv->direct_tir);
943 mlx5e_destroy_indirect_tirs(priv);
944 mlx5e_destroy_direct_rqts(priv, priv->direct_tir);
945 mlx5e_destroy_rqt(priv, &priv->indir_rqt);
946 mlx5e_close_drop_rq(&priv->drop_rq);
949 static int mlx5e_init_ul_rep_rx(struct mlx5e_priv *priv)
951 mlx5e_create_q_counters(priv);
952 return mlx5e_init_rep_rx(priv);
955 static void mlx5e_cleanup_ul_rep_rx(struct mlx5e_priv *priv)
957 mlx5e_cleanup_rep_rx(priv);
958 mlx5e_destroy_q_counters(priv);
961 static int mlx5e_init_uplink_rep_tx(struct mlx5e_rep_priv *rpriv)
963 struct mlx5_rep_uplink_priv *uplink_priv;
964 struct net_device *netdev;
965 struct mlx5e_priv *priv;
968 netdev = rpriv->netdev;
969 priv = netdev_priv(netdev);
970 uplink_priv = &rpriv->uplink_priv;
972 err = mlx5e_rep_tc_init(rpriv);
976 mlx5_init_port_tun_entropy(&uplink_priv->tun_entropy, priv->mdev);
978 mlx5e_rep_bond_init(rpriv);
979 err = mlx5e_rep_tc_netdevice_event_register(rpriv);
981 mlx5_core_err(priv->mdev, "Failed to register netdev notifier, err: %d\n",
989 mlx5e_rep_bond_cleanup(rpriv);
990 mlx5e_rep_tc_cleanup(rpriv);
994 static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
996 struct mlx5e_rep_priv *rpriv = priv->ppriv;
999 err = mlx5e_create_tises(priv);
1001 mlx5_core_warn(priv->mdev, "create tises failed, %d\n", err);
1005 if (rpriv->rep->vport == MLX5_VPORT_UPLINK) {
1006 err = mlx5e_init_uplink_rep_tx(rpriv);
1014 mlx5e_destroy_tises(priv);
1018 static void mlx5e_cleanup_uplink_rep_tx(struct mlx5e_rep_priv *rpriv)
1020 mlx5e_rep_tc_netdevice_event_unregister(rpriv);
1021 mlx5e_rep_bond_cleanup(rpriv);
1022 mlx5e_rep_tc_cleanup(rpriv);
1025 static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
1027 struct mlx5e_rep_priv *rpriv = priv->ppriv;
1029 mlx5e_destroy_tises(priv);
1031 if (rpriv->rep->vport == MLX5_VPORT_UPLINK)
1032 mlx5e_cleanup_uplink_rep_tx(rpriv);
1035 static void mlx5e_rep_enable(struct mlx5e_priv *priv)
1037 mlx5e_set_netdev_mtu_boundaries(priv);
1040 static int mlx5e_update_rep_rx(struct mlx5e_priv *priv)
1045 static int uplink_rep_async_event(struct notifier_block *nb, unsigned long event, void *data)
1047 struct mlx5e_priv *priv = container_of(nb, struct mlx5e_priv, events_nb);
1049 if (event == MLX5_EVENT_TYPE_PORT_CHANGE) {
1050 struct mlx5_eqe *eqe = data;
1052 switch (eqe->sub_type) {
1053 case MLX5_PORT_CHANGE_SUBTYPE_DOWN:
1054 case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE:
1055 queue_work(priv->wq, &priv->update_carrier_work);
1064 if (event == MLX5_DEV_EVENT_PORT_AFFINITY)
1065 return mlx5e_rep_tc_event_port_affinity(priv);
1070 static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
1072 struct net_device *netdev = priv->netdev;
1073 struct mlx5_core_dev *mdev = priv->mdev;
1076 netdev->min_mtu = ETH_MIN_MTU;
1077 mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1);
1078 netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu);
1079 mlx5e_set_dev_port_mtu(priv);
1081 mlx5e_rep_tc_enable(priv);
1083 mlx5_lag_add(mdev, netdev);
1084 priv->events_nb.notifier_call = uplink_rep_async_event;
1085 mlx5_notifier_register(mdev, &priv->events_nb);
1086 mlx5e_dcbnl_initialize(priv);
1087 mlx5e_dcbnl_init_app(priv);
1090 static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
1092 struct mlx5_core_dev *mdev = priv->mdev;
1094 mlx5e_dcbnl_delete_app(priv);
1095 mlx5_notifier_unregister(mdev, &priv->events_nb);
1096 mlx5e_rep_tc_disable(priv);
1097 mlx5_lag_remove(mdev);
1100 static MLX5E_DEFINE_STATS_GRP(sw_rep, 0);
1101 static MLX5E_DEFINE_STATS_GRP(vport_rep, MLX5E_NDO_UPDATE_STATS);
1103 /* The stats groups order is opposite to the update_stats() order calls */
1104 static mlx5e_stats_grp_t mlx5e_rep_stats_grps[] = {
1105 &MLX5E_STATS_GRP(sw_rep),
1106 &MLX5E_STATS_GRP(vport_rep),
1109 static unsigned int mlx5e_rep_stats_grps_num(struct mlx5e_priv *priv)
1111 return ARRAY_SIZE(mlx5e_rep_stats_grps);
1114 /* The stats groups order is opposite to the update_stats() order calls */
1115 static mlx5e_stats_grp_t mlx5e_ul_rep_stats_grps[] = {
1116 &MLX5E_STATS_GRP(sw),
1117 &MLX5E_STATS_GRP(qcnt),
1118 &MLX5E_STATS_GRP(vnic_env),
1119 &MLX5E_STATS_GRP(vport),
1120 &MLX5E_STATS_GRP(802_3),
1121 &MLX5E_STATS_GRP(2863),
1122 &MLX5E_STATS_GRP(2819),
1123 &MLX5E_STATS_GRP(phy),
1124 &MLX5E_STATS_GRP(eth_ext),
1125 &MLX5E_STATS_GRP(pcie),
1126 &MLX5E_STATS_GRP(per_prio),
1127 &MLX5E_STATS_GRP(pme),
1128 &MLX5E_STATS_GRP(channels),
1129 &MLX5E_STATS_GRP(per_port_buff_congest),
1132 static unsigned int mlx5e_ul_rep_stats_grps_num(struct mlx5e_priv *priv)
1134 return ARRAY_SIZE(mlx5e_ul_rep_stats_grps);
1137 static const struct mlx5e_profile mlx5e_rep_profile = {
1138 .init = mlx5e_init_rep,
1139 .cleanup = mlx5e_cleanup_rep,
1140 .init_rx = mlx5e_init_rep_rx,
1141 .cleanup_rx = mlx5e_cleanup_rep_rx,
1142 .init_tx = mlx5e_init_rep_tx,
1143 .cleanup_tx = mlx5e_cleanup_rep_tx,
1144 .enable = mlx5e_rep_enable,
1145 .update_rx = mlx5e_update_rep_rx,
1146 .update_stats = mlx5e_update_ndo_stats,
1147 .rx_handlers = &mlx5e_rx_handlers_rep,
1149 .rq_groups = MLX5E_NUM_RQ_GROUPS(REGULAR),
1150 .stats_grps = mlx5e_rep_stats_grps,
1151 .stats_grps_num = mlx5e_rep_stats_grps_num,
1154 static const struct mlx5e_profile mlx5e_uplink_rep_profile = {
1155 .init = mlx5e_init_rep,
1156 .cleanup = mlx5e_cleanup_rep,
1157 .init_rx = mlx5e_init_ul_rep_rx,
1158 .cleanup_rx = mlx5e_cleanup_ul_rep_rx,
1159 .init_tx = mlx5e_init_rep_tx,
1160 .cleanup_tx = mlx5e_cleanup_rep_tx,
1161 .enable = mlx5e_uplink_rep_enable,
1162 .disable = mlx5e_uplink_rep_disable,
1163 .update_rx = mlx5e_update_rep_rx,
1164 .update_stats = mlx5e_update_ndo_stats,
1165 .update_carrier = mlx5e_update_carrier,
1166 .rx_handlers = &mlx5e_rx_handlers_rep,
1167 .max_tc = MLX5E_MAX_NUM_TC,
1168 .rq_groups = MLX5E_NUM_RQ_GROUPS(REGULAR),
1169 .stats_grps = mlx5e_ul_rep_stats_grps,
1170 .stats_grps_num = mlx5e_ul_rep_stats_grps_num,
1174 is_devlink_port_supported(const struct mlx5_core_dev *dev,
1175 const struct mlx5e_rep_priv *rpriv)
1177 return rpriv->rep->vport == MLX5_VPORT_UPLINK ||
1178 rpriv->rep->vport == MLX5_VPORT_PF ||
1179 mlx5_eswitch_is_vf_vport(dev->priv.eswitch, rpriv->rep->vport);
1182 static int register_devlink_port(struct mlx5_core_dev *dev,
1183 struct mlx5e_rep_priv *rpriv)
1185 struct devlink *devlink = priv_to_devlink(dev);
1186 struct mlx5_eswitch_rep *rep = rpriv->rep;
1187 struct devlink_port_attrs attrs = {};
1188 struct netdev_phys_item_id ppid = {};
1189 unsigned int dl_port_index = 0;
1192 if (!is_devlink_port_supported(dev, rpriv))
1195 mlx5e_rep_get_port_parent_id(rpriv->netdev, &ppid);
1196 dl_port_index = mlx5_esw_vport_to_devlink_port_index(dev, rep->vport);
1197 pfnum = PCI_FUNC(dev->pdev->devfn);
1198 if (rep->vport == MLX5_VPORT_UPLINK) {
1199 attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
1200 attrs.phys.port_number = pfnum;
1201 memcpy(attrs.switch_id.id, &ppid.id[0], ppid.id_len);
1202 attrs.switch_id.id_len = ppid.id_len;
1203 devlink_port_attrs_set(&rpriv->dl_port, &attrs);
1204 } else if (rep->vport == MLX5_VPORT_PF) {
1205 memcpy(rpriv->dl_port.attrs.switch_id.id, &ppid.id[0], ppid.id_len);
1206 rpriv->dl_port.attrs.switch_id.id_len = ppid.id_len;
1207 devlink_port_attrs_pci_pf_set(&rpriv->dl_port, pfnum);
1208 } else if (mlx5_eswitch_is_vf_vport(dev->priv.eswitch, rpriv->rep->vport)) {
1209 memcpy(rpriv->dl_port.attrs.switch_id.id, &ppid.id[0], ppid.id_len);
1210 rpriv->dl_port.attrs.switch_id.id_len = ppid.id_len;
1211 devlink_port_attrs_pci_vf_set(&rpriv->dl_port,
1212 pfnum, rep->vport - 1);
1214 return devlink_port_register(devlink, &rpriv->dl_port, dl_port_index);
1217 static void unregister_devlink_port(struct mlx5_core_dev *dev,
1218 struct mlx5e_rep_priv *rpriv)
1220 if (is_devlink_port_supported(dev, rpriv))
1221 devlink_port_unregister(&rpriv->dl_port);
1224 /* e-Switch vport representors */
1226 mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
1228 const struct mlx5e_profile *profile;
1229 struct mlx5e_rep_priv *rpriv;
1230 struct net_device *netdev;
1233 rpriv = kzalloc(sizeof(*rpriv), GFP_KERNEL);
1237 /* rpriv->rep to be looked up when profile->init() is called */
1240 nch = mlx5e_get_max_num_channels(dev);
1241 profile = (rep->vport == MLX5_VPORT_UPLINK) ?
1242 &mlx5e_uplink_rep_profile : &mlx5e_rep_profile;
1243 netdev = mlx5e_create_netdev(dev, profile, nch, rpriv);
1246 "Failed to create representor netdev for vport %d\n",
1252 dev_net_set(netdev, mlx5_core_net(dev));
1253 rpriv->netdev = netdev;
1254 rep->rep_data[REP_ETH].priv = rpriv;
1255 INIT_LIST_HEAD(&rpriv->vport_sqs_list);
1257 if (rep->vport == MLX5_VPORT_UPLINK) {
1258 err = mlx5e_create_mdev_resources(dev);
1260 goto err_destroy_netdev;
1263 err = mlx5e_attach_netdev(netdev_priv(netdev));
1266 "Failed to attach representor netdev for vport %d\n",
1268 goto err_destroy_mdev_resources;
1271 err = mlx5e_rep_neigh_init(rpriv);
1274 "Failed to initialized neighbours handling for vport %d\n",
1276 goto err_detach_netdev;
1279 err = register_devlink_port(dev, rpriv);
1281 netdev_warn(netdev, "Failed to register devlink port %d\n",
1283 goto err_neigh_cleanup;
1286 err = register_netdev(netdev);
1289 "Failed to register representor netdev for vport %d\n",
1291 goto err_devlink_cleanup;
1294 if (is_devlink_port_supported(dev, rpriv))
1295 devlink_port_type_eth_set(&rpriv->dl_port, netdev);
1298 err_devlink_cleanup:
1299 unregister_devlink_port(dev, rpriv);
1302 mlx5e_rep_neigh_cleanup(rpriv);
1305 mlx5e_detach_netdev(netdev_priv(netdev));
1307 err_destroy_mdev_resources:
1308 if (rep->vport == MLX5_VPORT_UPLINK)
1309 mlx5e_destroy_mdev_resources(dev);
1312 mlx5e_destroy_netdev(netdev_priv(netdev));
1318 mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep)
1320 struct mlx5e_rep_priv *rpriv = mlx5e_rep_to_rep_priv(rep);
1321 struct net_device *netdev = rpriv->netdev;
1322 struct mlx5e_priv *priv = netdev_priv(netdev);
1323 struct mlx5_core_dev *dev = priv->mdev;
1324 void *ppriv = priv->ppriv;
1326 if (is_devlink_port_supported(dev, rpriv))
1327 devlink_port_type_clear(&rpriv->dl_port);
1328 unregister_netdev(netdev);
1329 unregister_devlink_port(dev, rpriv);
1330 mlx5e_rep_neigh_cleanup(rpriv);
1331 mlx5e_detach_netdev(priv);
1332 if (rep->vport == MLX5_VPORT_UPLINK)
1333 mlx5e_destroy_mdev_resources(priv->mdev);
1334 mlx5e_destroy_netdev(priv);
1335 kfree(ppriv); /* mlx5e_rep_priv */
1338 static void *mlx5e_vport_rep_get_proto_dev(struct mlx5_eswitch_rep *rep)
1340 struct mlx5e_rep_priv *rpriv;
1342 rpriv = mlx5e_rep_to_rep_priv(rep);
1344 return rpriv->netdev;
1347 static const struct mlx5_eswitch_rep_ops rep_ops = {
1348 .load = mlx5e_vport_rep_load,
1349 .unload = mlx5e_vport_rep_unload,
1350 .get_proto_dev = mlx5e_vport_rep_get_proto_dev
1353 void mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev)
1355 struct mlx5_eswitch *esw = mdev->priv.eswitch;
1357 mlx5_eswitch_register_vport_reps(esw, &rep_ops, REP_ETH);
1360 void mlx5e_rep_unregister_vport_reps(struct mlx5_core_dev *mdev)
1362 struct mlx5_eswitch *esw = mdev->priv.eswitch;
1364 mlx5_eswitch_unregister_vport_reps(esw, REP_ETH);