diff options
author | Rony Efraim <ronye@mellanox.com> | 2013-04-25 01:22:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-04-26 23:29:13 -0400 |
commit | 0eb62b93cbe0e8dea4cfe5ee761755e982663727 (patch) | |
tree | c831323f60d9018a3e7525e524497746fc810edd /drivers/net/ethernet/mellanox | |
parent | 6ce71acdea24cb742b2929983ca32cb962301bef (diff) |
net/mlx4: Add structures to keep VF Ethernet ports information
This patch add struct mlx4_vport_state where all the parameters related
to management of VFs port (virtual ports of the NIC eswitch) are kept.
The driver keeps an administrative and operational copy of the settings.
The current administrative copy becomes operational on the event of probing
a VF either on a VM or on the host.
Signed-off-by: Rony Efraim <ronye@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/cmd.c | 32 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/fw.c | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/mlx4.h | 26 |
3 files changed, 62 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 05267d716e86..0a301e1a0635 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c | |||
@@ -1490,6 +1490,16 @@ out: | |||
1490 | return ret; | 1490 | return ret; |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave) | ||
1494 | { | ||
1495 | int port; | ||
1496 | for (port = 1; port <= MLX4_MAX_PORTS; port++) { | ||
1497 | priv->mfunc.master.vf_oper[slave].vport[port].state = | ||
1498 | priv->mfunc.master.vf_admin[slave].vport[port]; | ||
1499 | } | ||
1500 | return 0; | ||
1501 | } | ||
1502 | |||
1493 | static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, | 1503 | static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, |
1494 | u16 param, u8 toggle) | 1504 | u16 param, u8 toggle) |
1495 | { | 1505 | { |
@@ -1556,6 +1566,7 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd, | |||
1556 | if (slave_state[slave].last_cmd != MLX4_COMM_CMD_VHCR2) | 1566 | if (slave_state[slave].last_cmd != MLX4_COMM_CMD_VHCR2) |
1557 | goto reset_slave; | 1567 | goto reset_slave; |
1558 | slave_state[slave].vhcr_dma |= param; | 1568 | slave_state[slave].vhcr_dma |= param; |
1569 | mlx4_master_activate_admin_state(priv, slave); | ||
1559 | slave_state[slave].active = true; | 1570 | slave_state[slave].active = true; |
1560 | mlx4_dispatch_event(dev, MLX4_DEV_EVENT_SLAVE_INIT, slave); | 1571 | mlx4_dispatch_event(dev, MLX4_DEV_EVENT_SLAVE_INIT, slave); |
1561 | break; | 1572 | break; |
@@ -1732,6 +1743,18 @@ int mlx4_multi_func_init(struct mlx4_dev *dev) | |||
1732 | if (!priv->mfunc.master.slave_state) | 1743 | if (!priv->mfunc.master.slave_state) |
1733 | goto err_comm; | 1744 | goto err_comm; |
1734 | 1745 | ||
1746 | priv->mfunc.master.vf_admin = | ||
1747 | kzalloc(dev->num_slaves * | ||
1748 | sizeof(struct mlx4_vf_admin_state), GFP_KERNEL); | ||
1749 | if (!priv->mfunc.master.vf_admin) | ||
1750 | goto err_comm_admin; | ||
1751 | |||
1752 | priv->mfunc.master.vf_oper = | ||
1753 | kzalloc(dev->num_slaves * | ||
1754 | sizeof(struct mlx4_vf_oper_state), GFP_KERNEL); | ||
1755 | if (!priv->mfunc.master.vf_oper) | ||
1756 | goto err_comm_oper; | ||
1757 | |||
1735 | for (i = 0; i < dev->num_slaves; ++i) { | 1758 | for (i = 0; i < dev->num_slaves; ++i) { |
1736 | s_state = &priv->mfunc.master.slave_state[i]; | 1759 | s_state = &priv->mfunc.master.slave_state[i]; |
1737 | s_state->last_cmd = MLX4_COMM_CMD_RESET; | 1760 | s_state->last_cmd = MLX4_COMM_CMD_RESET; |
@@ -1752,6 +1775,9 @@ int mlx4_multi_func_init(struct mlx4_dev *dev) | |||
1752 | goto err_slaves; | 1775 | goto err_slaves; |
1753 | } | 1776 | } |
1754 | INIT_LIST_HEAD(&s_state->mcast_filters[port]); | 1777 | INIT_LIST_HEAD(&s_state->mcast_filters[port]); |
1778 | priv->mfunc.master.vf_admin[i].vport[port].default_vlan = MLX4_VGT; | ||
1779 | priv->mfunc.master.vf_oper[i].vport[port].vlan_idx = NO_INDX; | ||
1780 | priv->mfunc.master.vf_oper[i].vport[port].mac_idx = NO_INDX; | ||
1755 | } | 1781 | } |
1756 | spin_lock_init(&s_state->lock); | 1782 | spin_lock_init(&s_state->lock); |
1757 | } | 1783 | } |
@@ -1800,6 +1826,10 @@ err_slaves: | |||
1800 | for (port = 1; port <= MLX4_MAX_PORTS; port++) | 1826 | for (port = 1; port <= MLX4_MAX_PORTS; port++) |
1801 | kfree(priv->mfunc.master.slave_state[i].vlan_filter[port]); | 1827 | kfree(priv->mfunc.master.slave_state[i].vlan_filter[port]); |
1802 | } | 1828 | } |
1829 | kfree(priv->mfunc.master.vf_oper); | ||
1830 | err_comm_oper: | ||
1831 | kfree(priv->mfunc.master.vf_admin); | ||
1832 | err_comm_admin: | ||
1803 | kfree(priv->mfunc.master.slave_state); | 1833 | kfree(priv->mfunc.master.slave_state); |
1804 | err_comm: | 1834 | err_comm: |
1805 | iounmap(priv->mfunc.comm); | 1835 | iounmap(priv->mfunc.comm); |
@@ -1874,6 +1904,8 @@ void mlx4_multi_func_cleanup(struct mlx4_dev *dev) | |||
1874 | kfree(priv->mfunc.master.slave_state[i].vlan_filter[port]); | 1904 | kfree(priv->mfunc.master.slave_state[i].vlan_filter[port]); |
1875 | } | 1905 | } |
1876 | kfree(priv->mfunc.master.slave_state); | 1906 | kfree(priv->mfunc.master.slave_state); |
1907 | kfree(priv->mfunc.master.vf_admin); | ||
1908 | kfree(priv->mfunc.master.vf_oper); | ||
1877 | } | 1909 | } |
1878 | 1910 | ||
1879 | iounmap(priv->mfunc.comm); | 1911 | iounmap(priv->mfunc.comm); |
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c index 1f6c3e9128ef..70d44adddc39 100644 --- a/drivers/net/ethernet/mellanox/mlx4/fw.c +++ b/drivers/net/ethernet/mellanox/mlx4/fw.c | |||
@@ -816,6 +816,7 @@ int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, | |||
816 | struct mlx4_cmd_mailbox *outbox, | 816 | struct mlx4_cmd_mailbox *outbox, |
817 | struct mlx4_cmd_info *cmd) | 817 | struct mlx4_cmd_info *cmd) |
818 | { | 818 | { |
819 | struct mlx4_priv *priv = mlx4_priv(dev); | ||
819 | u64 def_mac; | 820 | u64 def_mac; |
820 | u8 port_type; | 821 | u8 port_type; |
821 | u16 short_field; | 822 | u16 short_field; |
@@ -833,6 +834,9 @@ int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, | |||
833 | /* set slave default_mac address */ | 834 | /* set slave default_mac address */ |
834 | MLX4_GET(def_mac, outbox->buf, QUERY_PORT_MAC_OFFSET); | 835 | MLX4_GET(def_mac, outbox->buf, QUERY_PORT_MAC_OFFSET); |
835 | def_mac += slave << 8; | 836 | def_mac += slave << 8; |
837 | /* if config MAC in DB use it */ | ||
838 | if (priv->mfunc.master.vf_oper[slave].vport[vhcr->in_modifier].state.mac) | ||
839 | def_mac = priv->mfunc.master.vf_oper[slave].vport[vhcr->in_modifier].state.mac; | ||
836 | MLX4_PUT(outbox->buf, def_mac, QUERY_PORT_MAC_OFFSET); | 840 | MLX4_PUT(outbox->buf, def_mac, QUERY_PORT_MAC_OFFSET); |
837 | 841 | ||
838 | /* get port type - currently only eth is enabled */ | 842 | /* get port type - currently only eth is enabled */ |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h index 0567f01938ed..7e1d10059eda 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h | |||
@@ -473,6 +473,30 @@ struct mlx4_slave_state { | |||
473 | enum slave_port_state port_state[MLX4_MAX_PORTS + 1]; | 473 | enum slave_port_state port_state[MLX4_MAX_PORTS + 1]; |
474 | }; | 474 | }; |
475 | 475 | ||
476 | #define MLX4_VGT 4095 | ||
477 | #define NO_INDX (-1) | ||
478 | |||
479 | struct mlx4_vport_state { | ||
480 | u64 mac; | ||
481 | u16 default_vlan; | ||
482 | u8 default_qos; | ||
483 | u32 tx_rate; | ||
484 | bool spoofchk; | ||
485 | }; | ||
486 | |||
487 | struct mlx4_vf_admin_state { | ||
488 | struct mlx4_vport_state vport[MLX4_MAX_PORTS + 1]; | ||
489 | }; | ||
490 | |||
491 | struct mlx4_vport_oper_state { | ||
492 | struct mlx4_vport_state state; | ||
493 | int mac_idx; | ||
494 | int vlan_idx; | ||
495 | }; | ||
496 | struct mlx4_vf_oper_state { | ||
497 | struct mlx4_vport_oper_state vport[MLX4_MAX_PORTS + 1]; | ||
498 | }; | ||
499 | |||
476 | struct slave_list { | 500 | struct slave_list { |
477 | struct mutex mutex; | 501 | struct mutex mutex; |
478 | struct list_head res_list[MLX4_NUM_OF_RESOURCE_TYPE]; | 502 | struct list_head res_list[MLX4_NUM_OF_RESOURCE_TYPE]; |
@@ -503,6 +527,8 @@ struct mlx4_master_qp0_state { | |||
503 | 527 | ||
504 | struct mlx4_mfunc_master_ctx { | 528 | struct mlx4_mfunc_master_ctx { |
505 | struct mlx4_slave_state *slave_state; | 529 | struct mlx4_slave_state *slave_state; |
530 | struct mlx4_vf_admin_state *vf_admin; | ||
531 | struct mlx4_vf_oper_state *vf_oper; | ||
506 | struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1]; | 532 | struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1]; |
507 | int init_port_ref[MLX4_MAX_PORTS + 1]; | 533 | int init_port_ref[MLX4_MAX_PORTS + 1]; |
508 | u16 max_mtu[MLX4_MAX_PORTS + 1]; | 534 | u16 max_mtu[MLX4_MAX_PORTS + 1]; |