History

net/mlx5: E-Switch, Refactor eswitch SR-IOV interface

Devlink eswitch mode is not necessarily related to SR-IOV, e.g, ECPF can be at offload mode when SR-IOV is not enabled. Rename the interface and eswitch mode names to decouple from SR-IOV, and cleanup eswitch messages accordingly.

Bodong Wang committed 7 years ago

Commit f6455de1 parent e1d974d11 files · +77 −76Browse files

Unified · Split

11 files
  1. drivers/infiniband/hw/mlx5/ib_rep.h +1 −1
  2. drivers/infiniband/hw/mlx5/main.c +1 −1
  3. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 −1
  4. drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +3 −3
  5. drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 −1
  6. drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +43 −42
  7. drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +4 −4
  8. drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +16 −16
  9. drivers/net/ethernet/mellanox/mlx5/core/lag.c +2 −2
  10. drivers/net/ethernet/mellanox/mlx5/core/sriov.c +2 −2
  11. include/linux/mlx5/eswitch.h +3 −3
drivers/infiniband/hw/mlx5/ib_rep.h+1−1
@@ -28,7 +28,7 @@ struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, · 27 unmodified lines
28#else /* CONFIG_MLX5_ESWITCH */28#else /* CONFIG_MLX5_ESWITCH */
29static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)29static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
30{30{
31 return SRIOV_NONE;31 return MLX5_ESWITCH_NONE;
32}32}
33 33
34static inline34static inline
drivers/infiniband/hw/mlx5/main.c+1−1
@@ -6814,7 +6814,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) · 6813 unmodified lines
6814 printk_once(KERN_INFO "%s", mlx5_version);6814 printk_once(KERN_INFO "%s", mlx5_version);
6815 6815
6816 if (MLX5_ESWITCH_MANAGER(mdev) &&6816 if (MLX5_ESWITCH_MANAGER(mdev) &&
6817 mlx5_ib_eswitch_mode(mdev->priv.eswitch) == SRIOV_OFFLOADS) {6817 mlx5_ib_eswitch_mode(mdev->priv.eswitch) == MLX5_ESWITCH_OFFLOADS) {
6818 if (!mlx5_core_mp_enabled(mdev))6818 if (!mlx5_core_mp_enabled(mdev))
6819 mlx5_ib_register_vport_reps(mdev);6819 mlx5_ib_register_vport_reps(mdev);
6820 return mdev;6820 return mdev;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+1−1
@@ -5115,7 +5115,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev) · 5114 unmodified lines
5115 5115
5116#ifdef CONFIG_MLX5_ESWITCH5116#ifdef CONFIG_MLX5_ESWITCH
5117 if (MLX5_ESWITCH_MANAGER(mdev) &&5117 if (MLX5_ESWITCH_MANAGER(mdev) &&
5118 mlx5_eswitch_mode(mdev->priv.eswitch) == SRIOV_OFFLOADS) {5118 mlx5_eswitch_mode(mdev->priv.eswitch) == MLX5_ESWITCH_OFFLOADS) {
5119 mlx5e_rep_register_vport_reps(mdev);5119 mlx5e_rep_register_vport_reps(mdev);
5120 return mdev;5120 return mdev;
5121 }5121 }
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c+3−3
@@ -391,7 +391,7 @@ static int mlx5e_rep_get_port_parent_id(struct net_device *dev, · 390 unmodified lines
391 struct mlx5e_priv *uplink_priv = NULL;391 struct mlx5e_priv *uplink_priv = NULL;
392 struct net_device *uplink_dev;392 struct net_device *uplink_dev;
393 393
394 if (esw->mode == SRIOV_NONE)394 if (esw->mode == MLX5_ESWITCH_NONE)
395 return -EOPNOTSUPP;395 return -EOPNOTSUPP;
396 396
397 uplink_dev = mlx5_eswitch_uplink_get_proto_dev(esw, REP_ETH);397 uplink_dev = mlx5_eswitch_uplink_get_proto_dev(esw, REP_ETH);
@@ -419,7 +419,7 @@ static void mlx5e_sqs2vport_stop(struct mlx5_eswitch *esw, · 21 unmodified lines
419 struct mlx5e_rep_sq *rep_sq, *tmp;419 struct mlx5e_rep_sq *rep_sq, *tmp;
420 struct mlx5e_rep_priv *rpriv;420 struct mlx5e_rep_priv *rpriv;
421 421
422 if (esw->mode != SRIOV_OFFLOADS)422 if (esw->mode != MLX5_ESWITCH_OFFLOADS)
423 return;423 return;
424 424
425 rpriv = mlx5e_rep_to_rep_priv(rep);425 rpriv = mlx5e_rep_to_rep_priv(rep);
@@ -440,7 +440,7 @@ static int mlx5e_sqs2vport_start(struct mlx5_eswitch *esw, · 14 unmodified lines
440 int err;440 int err;
441 int i;441 int i;
442 442
443 if (esw->mode != SRIOV_OFFLOADS)443 if (esw->mode != MLX5_ESWITCH_OFFLOADS)
444 return 0;444 return 0;
445 445
446 rpriv = mlx5e_rep_to_rep_priv(rep);446 rpriv = mlx5e_rep_to_rep_priv(rep);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c+1−1
@@ -3342,7 +3342,7 @@ mlx5e_tc_add_flow(struct mlx5e_priv *priv, · 3341 unmodified lines
3342 if (!tc_can_offload_extack(priv->netdev, f->common.extack))3342 if (!tc_can_offload_extack(priv->netdev, f->common.extack))
3343 return -EOPNOTSUPP;3343 return -EOPNOTSUPP;
3344 3344
3345 if (esw && esw->mode == SRIOV_OFFLOADS)3345 if (esw && esw->mode == MLX5_ESWITCH_OFFLOADS)
3346 err = mlx5e_add_fdb_flow(priv, f, flow_flags,3346 err = mlx5e_add_fdb_flow(priv, f, flow_flags,
3347 filter_dev, flow);3347 filter_dev, flow);
3348 else3348 else
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c+43−42
@@ -497,7 +497,7 @@ static int esw_add_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr) · 496 unmodified lines
497 497
498fdb_add:498fdb_add:
499 /* SRIOV is enabled: Forward UC MAC to vport */499 /* SRIOV is enabled: Forward UC MAC to vport */
500 if (esw->fdb_table.legacy.fdb && esw->mode == SRIOV_LEGACY)500 if (esw->fdb_table.legacy.fdb && esw->mode == MLX5_ESWITCH_LEGACY)
501 vaddr->flow_rule = esw_fdb_set_vport_rule(esw, mac, vport);501 vaddr->flow_rule = esw_fdb_set_vport_rule(esw, mac, vport);
502 502
503 esw_debug(esw->dev, "\tADDED UC MAC: vport[%d] %pM fr(%p)\n",503 esw_debug(esw->dev, "\tADDED UC MAC: vport[%d] %pM fr(%p)\n",
@@ -1577,7 +1577,7 @@ static void esw_apply_vport_conf(struct mlx5_eswitch *esw, · 1073 unmodified lines
1577 flags);1577 flags);
1578 1578
1579 /* Only legacy mode needs ACLs */1579 /* Only legacy mode needs ACLs */
1580 if (esw->mode == SRIOV_LEGACY) {1580 if (esw->mode == MLX5_ESWITCH_LEGACY) {
1581 esw_vport_ingress_config(esw, vport);1581 esw_vport_ingress_config(esw, vport);
1582 esw_vport_egress_config(esw, vport);1582 esw_vport_egress_config(esw, vport);
1583 }1583 }
@@ -1629,7 +1629,7 @@ static void esw_enable_vport(struct mlx5_eswitch *esw, struct mlx5_vport *vport, · 45 unmodified lines
1629 esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num);1629 esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num);
1630 1630
1631 /* Create steering drop counters for ingress and egress ACLs */1631 /* Create steering drop counters for ingress and egress ACLs */
1632 if (vport_num && esw->mode == SRIOV_LEGACY)1632 if (vport_num && esw->mode == MLX5_ESWITCH_LEGACY)
1633 esw_vport_create_drop_counters(vport);1633 esw_vport_create_drop_counters(vport);
1634 1634
1635 /* Restore old vport configuration */1635 /* Restore old vport configuration */
@@ -1683,7 +1683,7 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, · 47 unmodified lines
1683 vport->enabled_events = 0;1683 vport->enabled_events = 0;
1684 esw_vport_disable_qos(esw, vport);1684 esw_vport_disable_qos(esw, vport);
1685 if (esw->manager_vport != vport_num &&1685 if (esw->manager_vport != vport_num &&
1686 esw->mode == SRIOV_LEGACY) {1686 esw->mode == MLX5_ESWITCH_LEGACY) {
1687 mlx5_modify_vport_admin_state(esw->dev,1687 mlx5_modify_vport_admin_state(esw->dev,
1688 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,1688 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
1689 vport_num, 1,1689 vport_num, 1,
@@ -1728,7 +1728,7 @@ int mlx5_esw_query_functions(struct mlx5_core_dev *dev, u32 *out, int outlen) · 38 unmodified lines
1728/* Public E-Switch API */1728/* Public E-Switch API */
1729#define ESW_ALLOWED(esw) ((esw) && MLX5_ESWITCH_MANAGER((esw)->dev))1729#define ESW_ALLOWED(esw) ((esw) && MLX5_ESWITCH_MANAGER((esw)->dev))
1730 1730
1731int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)1731int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int nvfs, int mode)
1732{1732{
1733 struct mlx5_vport *vport;1733 struct mlx5_vport *vport;
1734 int total_nvports = 0;1734 int total_nvports = 0;
@@ -1737,19 +1737,17 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) · 2 unmodified lines
1737 1737
1738 if (!ESW_ALLOWED(esw) ||1738 if (!ESW_ALLOWED(esw) ||
1739 !MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ft_support)) {1739 !MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ft_support)) {
1740 esw_warn(esw->dev, "E-Switch FDB is not supported, aborting ...\n");1740 esw_warn(esw->dev, "FDB is not supported, aborting ...\n");
1741 return -EOPNOTSUPP;1741 return -EOPNOTSUPP;
1742 }1742 }
1743 1743
1744 if (!MLX5_CAP_ESW_INGRESS_ACL(esw->dev, ft_support))1744 if (!MLX5_CAP_ESW_INGRESS_ACL(esw->dev, ft_support))
1745 esw_warn(esw->dev, "E-Switch ingress ACL is not supported by FW\n");1745 esw_warn(esw->dev, "ingress ACL is not supported by FW\n");
1746 1746
1747 if (!MLX5_CAP_ESW_EGRESS_ACL(esw->dev, ft_support))1747 if (!MLX5_CAP_ESW_EGRESS_ACL(esw->dev, ft_support))
1748 esw_warn(esw->dev, "E-Switch engress ACL is not supported by FW\n");1748 esw_warn(esw->dev, "engress ACL is not supported by FW\n");
1749 1749
1750 esw_info(esw->dev, "E-Switch enable SRIOV: nvfs(%d) mode (%d)\n", nvfs, mode);1750 if (mode == MLX5_ESWITCH_OFFLOADS) {
1751
1752 if (mode == SRIOV_OFFLOADS) {
1753 if (mlx5_core_is_ecpf_esw_manager(esw->dev))1751 if (mlx5_core_is_ecpf_esw_manager(esw->dev))
1754 total_nvports = esw->total_vports;1752 total_nvports = esw->total_vports;
1755 else1753 else
@@ -1760,7 +1758,7 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) · 4 unmodified lines
1760 1758
1761 mlx5_lag_update(esw->dev);1759 mlx5_lag_update(esw->dev);
1762 1760
1763 if (mode == SRIOV_LEGACY) {1761 if (mode == MLX5_ESWITCH_LEGACY) {
1764 err = esw_create_legacy_table(esw);1762 err = esw_create_legacy_table(esw);
1765 if (err)1763 if (err)
1766 goto abort;1764 goto abort;
@@ -1777,11 +1775,11 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) · 10 unmodified lines
1777 if (err)1775 if (err)
1778 esw_warn(esw->dev, "Failed to create eswitch TSAR");1776 esw_warn(esw->dev, "Failed to create eswitch TSAR");
1779 1777
1780 /* Don't enable vport events when in SRIOV_OFFLOADS mode, since:1778 /* Don't enable vport events when in MLX5_ESWITCH_OFFLOADS mode, since:
1781 * 1. L2 table (MPFS) is programmed by PF/VF representors netdevs set_rx_mode1779 * 1. L2 table (MPFS) is programmed by PF/VF representors netdevs set_rx_mode
1782 * 2. FDB/Eswitch is programmed by user space tools1780 * 2. FDB/Eswitch is programmed by user space tools
1783 */1781 */
1784 enabled_events = (mode == SRIOV_LEGACY) ? SRIOV_VPORT_EVENTS : 0;1782 enabled_events = (mode == MLX5_ESWITCH_LEGACY) ? SRIOV_VPORT_EVENTS : 0;
1785 1783
1786 /* Enable PF vport */1784 /* Enable PF vport */
1787 vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_PF);1785 vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_PF);
@@ -1797,19 +1795,21 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) · 9 unmodified lines
1797 mlx5_esw_for_each_vf_vport(esw, i, vport, nvfs)1795 mlx5_esw_for_each_vf_vport(esw, i, vport, nvfs)
1798 esw_enable_vport(esw, vport, enabled_events);1796 esw_enable_vport(esw, vport, enabled_events);
1799 1797
1800 if (mode == SRIOV_LEGACY) {1798 if (mode == MLX5_ESWITCH_LEGACY) {
1801 MLX5_NB_INIT(&esw->nb, eswitch_vport_event, NIC_VPORT_CHANGE);1799 MLX5_NB_INIT(&esw->nb, eswitch_vport_event, NIC_VPORT_CHANGE);
1802 mlx5_eq_notifier_register(esw->dev, &esw->nb);1800 mlx5_eq_notifier_register(esw->dev, &esw->nb);
1803 }1801 }
1804 1802
1805 esw_info(esw->dev, "SRIOV enabled: active vports(%d)\n",1803 esw_info(esw->dev, "Enable: mode(%s), nvfs(%d), active vports(%d)\n",
1806 esw->enabled_vports);1804 mode == MLX5_ESWITCH_LEGACY ? "LEGACY" : "OFFLOADS",
1805 nvfs, esw->enabled_vports);
1806
1807 return 0;1807 return 0;
1808 1808
1809abort:1809abort:
1810 esw->mode = SRIOV_NONE;1810 esw->mode = MLX5_ESWITCH_NONE;
1811 1811
1812 if (mode == SRIOV_OFFLOADS) {1812 if (mode == MLX5_ESWITCH_OFFLOADS) {
1813 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);1813 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
1814 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);1814 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
1815 }1815 }
@@ -1817,22 +1817,23 @@ abort: · 1 unmodified line
1817 return err;1817 return err;
1818}1818}
1819 1819
1820void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw)1820void mlx5_eswitch_disable(struct mlx5_eswitch *esw)
1821{1821{
1822 struct esw_mc_addr *mc_promisc;1822 struct esw_mc_addr *mc_promisc;
1823 struct mlx5_vport *vport;1823 struct mlx5_vport *vport;
1824 int old_mode;1824 int old_mode;
1825 int i;1825 int i;
1826 1826
1827 if (!ESW_ALLOWED(esw) || esw->mode == SRIOV_NONE)1827 if (!ESW_ALLOWED(esw) || esw->mode == MLX5_ESWITCH_NONE)
1828 return;1828 return;
1829 1829
1830 esw_info(esw->dev, "disable SRIOV: active vports(%d) mode(%d)\n",1830 esw_info(esw->dev, "Disable: mode(%s), nvfs(%d), active vports(%d)\n",
1831 esw->enabled_vports, esw->mode);1831 esw->mode == MLX5_ESWITCH_LEGACY ? "LEGACY" : "OFFLOADS",
1832 esw->dev->priv.sriov.num_vfs, esw->enabled_vports);
1832 1833
1833 mc_promisc = &esw->mc_promisc;1834 mc_promisc = &esw->mc_promisc;
1834 1835
1835 if (esw->mode == SRIOV_LEGACY)1836 if (esw->mode == MLX5_ESWITCH_LEGACY)
1836 mlx5_eq_notifier_unregister(esw->dev, &esw->nb);1837 mlx5_eq_notifier_unregister(esw->dev, &esw->nb);
1837 1838
1838 mlx5_esw_for_all_vports(esw, i, vport)1839 mlx5_esw_for_all_vports(esw, i, vport)
@@ -1843,17 +1844,17 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) · 4 unmodified lines
1843 1844
1844 esw_destroy_tsar(esw);1845 esw_destroy_tsar(esw);
1845 1846
1846 if (esw->mode == SRIOV_LEGACY)1847 if (esw->mode == MLX5_ESWITCH_LEGACY)
1847 esw_destroy_legacy_table(esw);1848 esw_destroy_legacy_table(esw);
1848 else if (esw->mode == SRIOV_OFFLOADS)1849 else if (esw->mode == MLX5_ESWITCH_OFFLOADS)
1849 esw_offloads_cleanup(esw);1850 esw_offloads_cleanup(esw);
1850 1851
1851 old_mode = esw->mode;1852 old_mode = esw->mode;
1852 esw->mode = SRIOV_NONE;1853 esw->mode = MLX5_ESWITCH_NONE;
1853 1854
1854 mlx5_lag_update(esw->dev);1855 mlx5_lag_update(esw->dev);
1855 1856
1856 if (old_mode == SRIOV_OFFLOADS) {1857 if (old_mode == MLX5_ESWITCH_OFFLOADS) {
1857 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);1858 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
1858 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);1859 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
1859 }1860 }
@@ -1914,7 +1915,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev) · 54 unmodified lines
1914 }1915 }
1915 1916
1916 esw->enabled_vports = 0;1917 esw->enabled_vports = 0;
1917 esw->mode = SRIOV_NONE;1918 esw->mode = MLX5_ESWITCH_NONE;
1918 esw->offloads.inline_mode = MLX5_INLINE_MODE_NONE;1919 esw->offloads.inline_mode = MLX5_INLINE_MODE_NONE;
1919 if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, reformat) &&1920 if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, reformat) &&
1920 MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap))1921 MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap))
@@ -1984,7 +1985,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw, · 63 unmodified lines
1984 1985
1985 ether_addr_copy(evport->info.mac, mac);1986 ether_addr_copy(evport->info.mac, mac);
1986 evport->info.node_guid = node_guid;1987 evport->info.node_guid = node_guid;
1987 if (evport->enabled && esw->mode == SRIOV_LEGACY)1988 if (evport->enabled && esw->mode == MLX5_ESWITCH_LEGACY)
1988 err = esw_vport_ingress_config(esw, evport);1989 err = esw_vport_ingress_config(esw, evport);
1989 1990
1990unlock:1991unlock:
@@ -2068,7 +2069,7 @@ int __mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, · 77 unmodified lines
2068 2069
2069 evport->info.vlan = vlan;2070 evport->info.vlan = vlan;
2070 evport->info.qos = qos;2071 evport->info.qos = qos;
2071 if (evport->enabled && esw->mode == SRIOV_LEGACY) {2072 if (evport->enabled && esw->mode == MLX5_ESWITCH_LEGACY) {
2072 err = esw_vport_ingress_config(esw, evport);2073 err = esw_vport_ingress_config(esw, evport);
2073 if (err)2074 if (err)
2074 goto unlock;2075 goto unlock;
@@ -2110,7 +2111,7 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, · 35 unmodified lines
2110 mlx5_core_warn(esw->dev,2111 mlx5_core_warn(esw->dev,
2111 "Spoofchk in set while MAC is invalid, vport(%d)\n",2112 "Spoofchk in set while MAC is invalid, vport(%d)\n",
2112 evport->vport);2113 evport->vport);
2113 if (evport->enabled && esw->mode == SRIOV_LEGACY)2114 if (evport->enabled && esw->mode == MLX5_ESWITCH_LEGACY)
2114 err = esw_vport_ingress_config(esw, evport);2115 err = esw_vport_ingress_config(esw, evport);
2115 if (err)2116 if (err)
2116 evport->info.spoofchk = pschk;2117 evport->info.spoofchk = pschk;
@@ -2206,7 +2207,7 @@ int mlx5_eswitch_set_vepa(struct mlx5_eswitch *esw, u8 setting) · 89 unmodified lines
2206 return -EPERM;2207 return -EPERM;
2207 2208
2208 mutex_lock(&esw->state_lock);2209 mutex_lock(&esw->state_lock);
2209 if (esw->mode != SRIOV_LEGACY) {2210 if (esw->mode != MLX5_ESWITCH_LEGACY) {
2210 err = -EOPNOTSUPP;2211 err = -EOPNOTSUPP;
2211 goto out;2212 goto out;
2212 }2213 }
@@ -2229,7 +2230,7 @@ int mlx5_eswitch_get_vepa(struct mlx5_eswitch *esw, u8 *setting) · 16 unmodified lines
2229 return -EPERM;2230 return -EPERM;
2230 2231
2231 mutex_lock(&esw->state_lock);2232 mutex_lock(&esw->state_lock);
2232 if (esw->mode != SRIOV_LEGACY) {2233 if (esw->mode != MLX5_ESWITCH_LEGACY) {
2233 err = -EOPNOTSUPP;2234 err = -EOPNOTSUPP;
2234 goto out;2235 goto out;
2235 }2236 }
@@ -2372,7 +2373,7 @@ static int mlx5_eswitch_query_vport_drop_stats(struct mlx5_core_dev *dev, · 136 unmodified lines
2372 u64 bytes = 0;2373 u64 bytes = 0;
2373 int err = 0;2374 int err = 0;
2374 2375
2375 if (!vport->enabled || esw->mode != SRIOV_LEGACY)2376 if (!vport->enabled || esw->mode != MLX5_ESWITCH_LEGACY)
2376 return 0;2377 return 0;
2377 2378
2378 if (vport->egress.drop_counter)2379 if (vport->egress.drop_counter)
@@ -2482,7 +2483,7 @@ free_out: · 103 unmodified lines
2482 2483
2483u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw)2484u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw)
2484{2485{
2485 return ESW_ALLOWED(esw) ? esw->mode : SRIOV_NONE;2486 return ESW_ALLOWED(esw) ? esw->mode : MLX5_ESWITCH_NONE;
2486}2487}
2487EXPORT_SYMBOL_GPL(mlx5_eswitch_mode);2488EXPORT_SYMBOL_GPL(mlx5_eswitch_mode);
2488 2489
@@ -2499,10 +2500,10 @@ EXPORT_SYMBOL(mlx5_eswitch_get_encap_mode); · 10 unmodified lines
2499 2500
2500bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1)2501bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1)
2501{2502{
2502 if ((dev0->priv.eswitch->mode == SRIOV_NONE &&2503 if ((dev0->priv.eswitch->mode == MLX5_ESWITCH_NONE &&
2503 dev1->priv.eswitch->mode == SRIOV_NONE) ||2504 dev1->priv.eswitch->mode == MLX5_ESWITCH_NONE) ||
2504 (dev0->priv.eswitch->mode == SRIOV_OFFLOADS &&2505 (dev0->priv.eswitch->mode == MLX5_ESWITCH_OFFLOADS &&
2505 dev1->priv.eswitch->mode == SRIOV_OFFLOADS))2506 dev1->priv.eswitch->mode == MLX5_ESWITCH_OFFLOADS))
2506 return true;2507 return true;
2507 2508
2508 return false;2509 return false;
@@ -2511,6 +2512,6 @@ bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1) · 2 unmodified lines
2511bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0,2512bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0,
2512 struct mlx5_core_dev *dev1)2513 struct mlx5_core_dev *dev1)
2513{2514{
2514 return (dev0->priv.eswitch->mode == SRIOV_OFFLOADS &&2515 return (dev0->priv.eswitch->mode == MLX5_ESWITCH_OFFLOADS &&
2515 dev1->priv.eswitch->mode == SRIOV_OFFLOADS);2516 dev1->priv.eswitch->mode == MLX5_ESWITCH_OFFLOADS);
2516}2517}
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h+4−4
@@ -253,8 +253,8 @@ void esw_vport_del_ingress_acl_modify_metadata(struct mlx5_eswitch *esw, · 252 unmodified lines
253/* E-Switch API */253/* E-Switch API */
254int mlx5_eswitch_init(struct mlx5_core_dev *dev);254int mlx5_eswitch_init(struct mlx5_core_dev *dev);
255void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw);255void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw);
256int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode);256int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int nvfs, int mode);
257void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw);257void mlx5_eswitch_disable(struct mlx5_eswitch *esw);
258int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,258int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
259 int vport, u8 mac[ETH_ALEN]);259 int vport, u8 mac[ETH_ALEN]);
260int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,260int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
@@ -528,8 +528,8 @@ bool mlx5_eswitch_is_vf_vport(const struct mlx5_eswitch *esw, u16 vport_num); · 267 unmodified lines
528/* eswitch API stubs */528/* eswitch API stubs */
529static inline int mlx5_eswitch_init(struct mlx5_core_dev *dev) { return 0; }529static inline int mlx5_eswitch_init(struct mlx5_core_dev *dev) { return 0; }
530static inline void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) {}530static inline void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) {}
531static inline int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) { return 0; }531static inline int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int nvfs, int mode) { return 0; }
532static inline void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) {}532static inline void mlx5_eswitch_disable(struct mlx5_eswitch *esw) {}
533static inline bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1) { return true; }533static inline bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1) { return true; }
534static inline bool mlx5_eswitch_is_funcs_handler(struct mlx5_core_dev *dev) { return false; }534static inline bool mlx5_eswitch_is_funcs_handler(struct mlx5_core_dev *dev) { return false; }
535static inline int535static inline int
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c+16−16
@@ -147,7 +147,7 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, · 146 unmodified lines
147 struct mlx5_flow_table *fdb;147 struct mlx5_flow_table *fdb;
148 int j, i = 0;148 int j, i = 0;
149 149
150 if (esw->mode != SRIOV_OFFLOADS)150 if (esw->mode != MLX5_ESWITCH_OFFLOADS)
151 return ERR_PTR(-EOPNOTSUPP);151 return ERR_PTR(-EOPNOTSUPP);
152 152
153 flow_act.action = attr->action;153 flow_act.action = attr->action;
@@ -1358,19 +1358,19 @@ static int esw_offloads_start(struct mlx5_eswitch *esw, · 1204 unmodified lines
1358{1358{
1359 int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs;1359 int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs;
1360 1360
1361 if (esw->mode != SRIOV_LEGACY &&1361 if (esw->mode != MLX5_ESWITCH_LEGACY &&
1362 !mlx5_core_is_ecpf_esw_manager(esw->dev)) {1362 !mlx5_core_is_ecpf_esw_manager(esw->dev)) {
1363 NL_SET_ERR_MSG_MOD(extack,1363 NL_SET_ERR_MSG_MOD(extack,
1364 "Can't set offloads mode, SRIOV legacy not enabled");1364 "Can't set offloads mode, SRIOV legacy not enabled");
1365 return -EINVAL;1365 return -EINVAL;
1366 }1366 }
1367 1367
1368 mlx5_eswitch_disable_sriov(esw);1368 mlx5_eswitch_disable(esw);
1369 err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_OFFLOADS);1369 err = mlx5_eswitch_enable(esw, num_vfs, MLX5_ESWITCH_OFFLOADS);
1370 if (err) {1370 if (err) {
1371 NL_SET_ERR_MSG_MOD(extack,1371 NL_SET_ERR_MSG_MOD(extack,
1372 "Failed setting eswitch to offloads");1372 "Failed setting eswitch to offloads");
1373 err1 = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY);1373 err1 = mlx5_eswitch_enable(esw, num_vfs, MLX5_ESWITCH_LEGACY);
1374 if (err1) {1374 if (err1) {
1375 NL_SET_ERR_MSG_MOD(extack,1375 NL_SET_ERR_MSG_MOD(extack,
1376 "Failed setting eswitch back to legacy");1376 "Failed setting eswitch back to legacy");
@@ -2174,11 +2174,11 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw, · 797 unmodified lines
2174{2174{
2175 int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs;2175 int err, err1, num_vfs = esw->dev->priv.sriov.num_vfs;
2176 2176
2177 mlx5_eswitch_disable_sriov(esw);2177 mlx5_eswitch_disable(esw);
2178 err = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY);2178 err = mlx5_eswitch_enable(esw, num_vfs, MLX5_ESWITCH_LEGACY);
2179 if (err) {2179 if (err) {
2180 NL_SET_ERR_MSG_MOD(extack, "Failed setting eswitch to legacy");2180 NL_SET_ERR_MSG_MOD(extack, "Failed setting eswitch to legacy");
2181 err1 = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_OFFLOADS);2181 err1 = mlx5_eswitch_enable(esw, num_vfs, MLX5_ESWITCH_OFFLOADS);
2182 if (err1) {2182 if (err1) {
2183 NL_SET_ERR_MSG_MOD(extack,2183 NL_SET_ERR_MSG_MOD(extack,
2184 "Failed setting eswitch back to offloads");2184 "Failed setting eswitch back to offloads");
@@ -2203,10 +2203,10 @@ static int esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) · 18 unmodified lines
2203{2203{
2204 switch (mode) {2204 switch (mode) {
2205 case DEVLINK_ESWITCH_MODE_LEGACY:2205 case DEVLINK_ESWITCH_MODE_LEGACY:
2206 *mlx5_mode = SRIOV_LEGACY;2206 *mlx5_mode = MLX5_ESWITCH_LEGACY;
2207 break;2207 break;
2208 case DEVLINK_ESWITCH_MODE_SWITCHDEV:2208 case DEVLINK_ESWITCH_MODE_SWITCHDEV:
2209 *mlx5_mode = SRIOV_OFFLOADS;2209 *mlx5_mode = MLX5_ESWITCH_OFFLOADS;
2210 break;2210 break;
2211 default:2211 default:
2212 return -EINVAL;2212 return -EINVAL;
@@ -2218,10 +2218,10 @@ static int esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) · 5 unmodified lines
2218static int esw_mode_to_devlink(u16 mlx5_mode, u16 *mode)2218static int esw_mode_to_devlink(u16 mlx5_mode, u16 *mode)
2219{2219{
2220 switch (mlx5_mode) {2220 switch (mlx5_mode) {
2221 case SRIOV_LEGACY:2221 case MLX5_ESWITCH_LEGACY:
2222 *mode = DEVLINK_ESWITCH_MODE_LEGACY;2222 *mode = DEVLINK_ESWITCH_MODE_LEGACY;
2223 break;2223 break;
2224 case SRIOV_OFFLOADS:2224 case MLX5_ESWITCH_OFFLOADS:
2225 *mode = DEVLINK_ESWITCH_MODE_SWITCHDEV;2225 *mode = DEVLINK_ESWITCH_MODE_SWITCHDEV;
2226 break;2226 break;
2227 default:2227 default:
@@ -2285,7 +2285,7 @@ static int mlx5_devlink_eswitch_check(struct devlink *devlink) · 57 unmodified lines
2285 if(!MLX5_ESWITCH_MANAGER(dev))2285 if(!MLX5_ESWITCH_MANAGER(dev))
2286 return -EPERM;2286 return -EPERM;
2287 2287
2288 if (dev->priv.eswitch->mode == SRIOV_NONE &&2288 if (dev->priv.eswitch->mode == MLX5_ESWITCH_NONE &&
2289 !mlx5_core_is_ecpf_esw_manager(dev))2289 !mlx5_core_is_ecpf_esw_manager(dev))
2290 return -EOPNOTSUPP;2290 return -EOPNOTSUPP;
2291 2291
@@ -2408,7 +2408,7 @@ int mlx5_eswitch_inline_mode_get(struct mlx5_eswitch *esw, int nvfs, u8 *mode) · 116 unmodified lines
2408 if (!MLX5_CAP_GEN(dev, vport_group_manager))2408 if (!MLX5_CAP_GEN(dev, vport_group_manager))
2409 return -EOPNOTSUPP;2409 return -EOPNOTSUPP;
2410 2410
2411 if (esw->mode == SRIOV_NONE)2411 if (esw->mode == MLX5_ESWITCH_NONE)
2412 return -EOPNOTSUPP;2412 return -EOPNOTSUPP;
2413 2413
2414 switch (MLX5_CAP_ETH(dev, wqe_inline_mode)) {2414 switch (MLX5_CAP_ETH(dev, wqe_inline_mode)) {
@@ -2455,7 +2455,7 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink, · 40 unmodified lines
2455 if (encap && encap != DEVLINK_ESWITCH_ENCAP_MODE_BASIC)2455 if (encap && encap != DEVLINK_ESWITCH_ENCAP_MODE_BASIC)
2456 return -EOPNOTSUPP;2456 return -EOPNOTSUPP;
2457 2457
2458 if (esw->mode == SRIOV_LEGACY) {2458 if (esw->mode == MLX5_ESWITCH_LEGACY) {
2459 esw->offloads.encap = encap;2459 esw->offloads.encap = encap;
2460 return 0;2460 return 0;
2461 }2461 }
@@ -2522,7 +2522,7 @@ void mlx5_eswitch_unregister_vport_reps(struct mlx5_eswitch *esw, u8 rep_type) · 60 unmodified lines
2522 struct mlx5_eswitch_rep *rep;2522 struct mlx5_eswitch_rep *rep;
2523 int i;2523 int i;
2524 2524
2525 if (esw->mode == SRIOV_OFFLOADS)2525 if (esw->mode == MLX5_ESWITCH_OFFLOADS)
2526 __unload_reps_all_vport(esw, max_vf, rep_type);2526 __unload_reps_all_vport(esw, max_vf, rep_type);
2527 2527
2528 mlx5_esw_for_all_reps(esw, i, rep)2528 mlx5_esw_for_all_reps(esw, i, rep)
drivers/net/ethernet/mellanox/mlx5/core/lag.c+2−2
@@ -305,8 +305,8 @@ static void mlx5_do_bond(struct mlx5_lag *ldev) · 304 unmodified lines
305 !mlx5_sriov_is_enabled(dev1);305 !mlx5_sriov_is_enabled(dev1);
306 306
307#ifdef CONFIG_MLX5_ESWITCH307#ifdef CONFIG_MLX5_ESWITCH
308 roce_lag &= dev0->priv.eswitch->mode == SRIOV_NONE &&308 roce_lag &= dev0->priv.eswitch->mode == MLX5_ESWITCH_NONE &&
309 dev1->priv.eswitch->mode == SRIOV_NONE;309 dev1->priv.eswitch->mode == MLX5_ESWITCH_NONE;
310#endif310#endif
311 311
312 if (roce_lag)312 if (roce_lag)
drivers/net/ethernet/mellanox/mlx5/core/sriov.c+2−2
@@ -77,7 +77,7 @@ static int mlx5_device_enable_sriov(struct mlx5_core_dev *dev, int num_vfs) · 76 unmodified lines
77 if (!MLX5_ESWITCH_MANAGER(dev))77 if (!MLX5_ESWITCH_MANAGER(dev))
78 goto enable_vfs_hca;78 goto enable_vfs_hca;
79 79
80 err = mlx5_eswitch_enable_sriov(dev->priv.eswitch, num_vfs, SRIOV_LEGACY);80 err = mlx5_eswitch_enable(dev->priv.eswitch, num_vfs, MLX5_ESWITCH_LEGACY);
81 if (err) {81 if (err) {
82 mlx5_core_warn(dev,82 mlx5_core_warn(dev,
83 "failed to enable eswitch SRIOV (%d)\n", err);83 "failed to enable eswitch SRIOV (%d)\n", err);
@@ -126,7 +126,7 @@ static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev) · 42 unmodified lines
126 }126 }
127 127
128 if (MLX5_ESWITCH_MANAGER(dev))128 if (MLX5_ESWITCH_MANAGER(dev))
129 mlx5_eswitch_disable_sriov(dev->priv.eswitch);129 mlx5_eswitch_disable(dev->priv.eswitch);
130 130
131 if (mlx5_wait_for_pages(dev, &dev->priv.vfs_pages))131 if (mlx5_wait_for_pages(dev, &dev->priv.vfs_pages))
132 mlx5_core_warn(dev, "timeout reclaiming VFs pages\n");132 mlx5_core_warn(dev, "timeout reclaiming VFs pages\n");
include/linux/mlx5/eswitch.h+3−3
@@ -12,9 +12,9 @@ · 11 unmodified lines
12#define MLX5_ESWITCH_MANAGER(mdev) MLX5_CAP_GEN(mdev, eswitch_manager)12#define MLX5_ESWITCH_MANAGER(mdev) MLX5_CAP_GEN(mdev, eswitch_manager)
13 13
14enum {14enum {
15 SRIOV_NONE,15 MLX5_ESWITCH_NONE,
16 SRIOV_LEGACY,16 MLX5_ESWITCH_LEGACY,
17 SRIOV_OFFLOADS17 MLX5_ESWITCH_OFFLOADS
18};18};
19 19
20enum {20enum {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t