diff options
author | Rony Efraim <ronye@mellanox.com> | 2013-04-25 01:22:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-04-26 23:29:13 -0400 |
commit | 8f7ba3ca12f6f16526fa4a8aaf2cae91563eee69 (patch) | |
tree | 4bf50f09e298b484003cd545b9ffa5d656915a98 | |
parent | 0eb62b93cbe0e8dea4cfe5ee761755e982663727 (diff) |
net/mlx4: Add set VF mac address support
Add ndo_set_vf_mac support which allows to set the MAC address
for mlx4 VF Ethernet NICs from 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>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/cmd.c | 31 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 42 | ||||
-rw-r--r-- | include/linux/mlx4/cmd.h | 1 |
3 files changed, 73 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 0a301e1a0635..a029124fe2f8 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c | |||
@@ -2016,3 +2016,34 @@ u32 mlx4_comm_get_version(void) | |||
2016 | { | 2016 | { |
2017 | return ((u32) CMD_CHAN_IF_REV << 8) | (u32) CMD_CHAN_VER; | 2017 | return ((u32) CMD_CHAN_IF_REV << 8) | (u32) CMD_CHAN_VER; |
2018 | } | 2018 | } |
2019 | |||
2020 | static int mlx4_get_slave_indx(struct mlx4_dev *dev, int vf) | ||
2021 | { | ||
2022 | if ((vf < 0) || (vf >= dev->num_vfs)) { | ||
2023 | mlx4_err(dev, "Bad vf number:%d (number of activated vf: %d)\n", vf, dev->num_vfs); | ||
2024 | return -EINVAL; | ||
2025 | } | ||
2026 | |||
2027 | return vf+1; | ||
2028 | } | ||
2029 | |||
2030 | int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac) | ||
2031 | { | ||
2032 | struct mlx4_priv *priv = mlx4_priv(dev); | ||
2033 | struct mlx4_vport_state *s_info; | ||
2034 | int slave; | ||
2035 | |||
2036 | if (!mlx4_is_master(dev)) | ||
2037 | return -EPROTONOSUPPORT; | ||
2038 | |||
2039 | slave = mlx4_get_slave_indx(dev, vf); | ||
2040 | if (slave < 0) | ||
2041 | return -EINVAL; | ||
2042 | |||
2043 | s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; | ||
2044 | s_info->mac = mac; | ||
2045 | mlx4_info(dev, "default mac on vf %d port %d to %llX will take afect only after vf restart\n", | ||
2046 | vf, port, s_info->mac); | ||
2047 | return 0; | ||
2048 | } | ||
2049 | EXPORT_SYMBOL_GPL(mlx4_set_vf_mac); | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 05c7c13bdbde..8293a92bf151 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
@@ -2024,6 +2024,19 @@ static int mlx4_en_set_features(struct net_device *netdev, | |||
2024 | 2024 | ||
2025 | } | 2025 | } |
2026 | 2026 | ||
2027 | static int mlx4_en_set_vf_mac(struct net_device *dev, int queue, u8 *mac) | ||
2028 | { | ||
2029 | struct mlx4_en_priv *en_priv = netdev_priv(dev); | ||
2030 | struct mlx4_en_dev *mdev = en_priv->mdev; | ||
2031 | u64 mac_u64 = mlx4_en_mac_to_u64(mac); | ||
2032 | |||
2033 | if (!is_valid_ether_addr(mac)) | ||
2034 | return -EINVAL; | ||
2035 | |||
2036 | return mlx4_set_vf_mac(mdev->dev, en_priv->port, queue, mac_u64); | ||
2037 | } | ||
2038 | |||
2039 | |||
2027 | static const struct net_device_ops mlx4_netdev_ops = { | 2040 | static const struct net_device_ops mlx4_netdev_ops = { |
2028 | .ndo_open = mlx4_en_open, | 2041 | .ndo_open = mlx4_en_open, |
2029 | .ndo_stop = mlx4_en_close, | 2042 | .ndo_stop = mlx4_en_close, |
@@ -2048,6 +2061,30 @@ static const struct net_device_ops mlx4_netdev_ops = { | |||
2048 | #endif | 2061 | #endif |
2049 | }; | 2062 | }; |
2050 | 2063 | ||
2064 | static const struct net_device_ops mlx4_netdev_ops_master = { | ||
2065 | .ndo_open = mlx4_en_open, | ||
2066 | .ndo_stop = mlx4_en_close, | ||
2067 | .ndo_start_xmit = mlx4_en_xmit, | ||
2068 | .ndo_select_queue = mlx4_en_select_queue, | ||
2069 | .ndo_get_stats = mlx4_en_get_stats, | ||
2070 | .ndo_set_rx_mode = mlx4_en_set_rx_mode, | ||
2071 | .ndo_set_mac_address = mlx4_en_set_mac, | ||
2072 | .ndo_validate_addr = eth_validate_addr, | ||
2073 | .ndo_change_mtu = mlx4_en_change_mtu, | ||
2074 | .ndo_tx_timeout = mlx4_en_tx_timeout, | ||
2075 | .ndo_vlan_rx_add_vid = mlx4_en_vlan_rx_add_vid, | ||
2076 | .ndo_vlan_rx_kill_vid = mlx4_en_vlan_rx_kill_vid, | ||
2077 | .ndo_set_vf_mac = mlx4_en_set_vf_mac, | ||
2078 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
2079 | .ndo_poll_controller = mlx4_en_netpoll, | ||
2080 | #endif | ||
2081 | .ndo_set_features = mlx4_en_set_features, | ||
2082 | .ndo_setup_tc = mlx4_en_setup_tc, | ||
2083 | #ifdef CONFIG_RFS_ACCEL | ||
2084 | .ndo_rx_flow_steer = mlx4_en_filter_rfs, | ||
2085 | #endif | ||
2086 | }; | ||
2087 | |||
2051 | int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | 2088 | int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, |
2052 | struct mlx4_en_port_profile *prof) | 2089 | struct mlx4_en_port_profile *prof) |
2053 | { | 2090 | { |
@@ -2164,7 +2201,10 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | |||
2164 | /* | 2201 | /* |
2165 | * Initialize netdev entry points | 2202 | * Initialize netdev entry points |
2166 | */ | 2203 | */ |
2167 | dev->netdev_ops = &mlx4_netdev_ops; | 2204 | if (mlx4_is_master(priv->mdev->dev)) |
2205 | dev->netdev_ops = &mlx4_netdev_ops_master; | ||
2206 | else | ||
2207 | dev->netdev_ops = &mlx4_netdev_ops; | ||
2168 | dev->watchdog_timeo = MLX4_EN_WATCHDOG_TIMEOUT; | 2208 | dev->watchdog_timeo = MLX4_EN_WATCHDOG_TIMEOUT; |
2169 | netif_set_real_num_tx_queues(dev, priv->tx_ring_num); | 2209 | netif_set_real_num_tx_queues(dev, priv->tx_ring_num); |
2170 | netif_set_real_num_rx_queues(dev, priv->rx_ring_num); | 2210 | netif_set_real_num_rx_queues(dev, priv->rx_ring_num); |
diff --git a/include/linux/mlx4/cmd.h b/include/linux/mlx4/cmd.h index 260695186256..f21ddc6203bd 100644 --- a/include/linux/mlx4/cmd.h +++ b/include/linux/mlx4/cmd.h | |||
@@ -232,6 +232,7 @@ struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev); | |||
232 | void mlx4_free_cmd_mailbox(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox); | 232 | void mlx4_free_cmd_mailbox(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox); |
233 | 233 | ||
234 | u32 mlx4_comm_get_version(void); | 234 | u32 mlx4_comm_get_version(void); |
235 | int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac); | ||
235 | 236 | ||
236 | #define MLX4_COMM_GET_IF_REV(cmd_chan_ver) (u8)((cmd_chan_ver) >> 8) | 237 | #define MLX4_COMM_GET_IF_REV(cmd_chan_ver) (u8)((cmd_chan_ver) >> 8) |
237 | 238 | ||