|
47 | 47 |
|
48 | 48 | static int mlx4_en_setup_tc(struct net_device *dev, u8 up) |
49 | 49 | { |
50 | | - if (up != MLX4_EN_NUM_UP) |
| 50 | + struct mlx4_en_priv *priv = netdev_priv(dev); |
| 51 | + int i; |
| 52 | + unsigned int q, offset = 0; |
| 53 | + |
| 54 | + if (up && up != MLX4_EN_NUM_UP) |
51 | 55 | return -EINVAL; |
52 | 56 |
|
| 57 | + netdev_set_num_tc(dev, up); |
| 58 | + |
| 59 | + /* Partition Tx queues evenly amongst UP's */ |
| 60 | + q = priv->tx_ring_num / up; |
| 61 | + for (i = 0; i < up; i++) { |
| 62 | + netdev_set_tc_queue(dev, i, q, offset); |
| 63 | + offset += q; |
| 64 | + } |
| 65 | + |
53 | 66 | return 0; |
54 | 67 | } |
55 | 68 |
|
@@ -661,7 +674,7 @@ int mlx4_en_start_port(struct net_device *dev) |
661 | 674 | /* Configure ring */ |
662 | 675 | tx_ring = &priv->tx_ring[i]; |
663 | 676 | err = mlx4_en_activate_tx_ring(priv, tx_ring, cq->mcq.cqn, |
664 | | - max(0, i - MLX4_EN_NUM_TX_RINGS)); |
| 677 | + i / priv->mdev->profile.num_tx_rings_p_up); |
665 | 678 | if (err) { |
666 | 679 | en_err(priv, "Failed allocating Tx ring\n"); |
667 | 680 | mlx4_en_deactivate_cq(priv, cq); |
@@ -986,6 +999,9 @@ void mlx4_en_destroy_netdev(struct net_device *dev) |
986 | 999 |
|
987 | 1000 | mlx4_en_free_resources(priv); |
988 | 1001 |
|
| 1002 | + kfree(priv->tx_ring); |
| 1003 | + kfree(priv->tx_cq); |
| 1004 | + |
989 | 1005 | free_netdev(dev); |
990 | 1006 | } |
991 | 1007 |
|
@@ -1091,6 +1107,18 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, |
1091 | 1107 | priv->ctrl_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE | |
1092 | 1108 | MLX4_WQE_CTRL_SOLICITED); |
1093 | 1109 | priv->tx_ring_num = prof->tx_ring_num; |
| 1110 | + priv->tx_ring = kzalloc(sizeof(struct mlx4_en_tx_ring) * |
| 1111 | + priv->tx_ring_num, GFP_KERNEL); |
| 1112 | + if (!priv->tx_ring) { |
| 1113 | + err = -ENOMEM; |
| 1114 | + goto out; |
| 1115 | + } |
| 1116 | + priv->tx_cq = kzalloc(sizeof(struct mlx4_en_cq) * priv->tx_ring_num, |
| 1117 | + GFP_KERNEL); |
| 1118 | + if (!priv->tx_cq) { |
| 1119 | + err = -ENOMEM; |
| 1120 | + goto out; |
| 1121 | + } |
1094 | 1122 | priv->rx_ring_num = prof->rx_ring_num; |
1095 | 1123 | priv->mac_index = -1; |
1096 | 1124 | priv->msg_enable = MLX4_EN_MSG_LEVEL; |
@@ -1138,15 +1166,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, |
1138 | 1166 | netif_set_real_num_tx_queues(dev, priv->tx_ring_num); |
1139 | 1167 | netif_set_real_num_rx_queues(dev, priv->rx_ring_num); |
1140 | 1168 |
|
1141 | | - netdev_set_num_tc(dev, MLX4_EN_NUM_UP); |
1142 | | - |
1143 | | - /* First 9 rings are for UP 0 */ |
1144 | | - netdev_set_tc_queue(dev, 0, MLX4_EN_NUM_TX_RINGS + 1, 0); |
1145 | | - |
1146 | | - /* Partition Tx queues evenly amongst UP's 1-7 */ |
1147 | | - for (i = 1; i < MLX4_EN_NUM_UP; i++) |
1148 | | - netdev_set_tc_queue(dev, i, 1, MLX4_EN_NUM_TX_RINGS + i); |
1149 | | - |
1150 | 1169 | SET_ETHTOOL_OPS(dev, &mlx4_en_ethtool_ops); |
1151 | 1170 |
|
1152 | 1171 | /* Set defualt MAC */ |
|
0 commit comments