diff options
-rw-r--r-- | drivers/infiniband/hw/mlx4/mad.c | 6 | ||||
-rw-r--r-- | drivers/infiniband/hw/mlx4/main.c | 11 | ||||
-rw-r--r-- | drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 | ||||
-rw-r--r-- | drivers/net/mlx4/fw.c | 4 | ||||
-rw-r--r-- | drivers/net/mlx4/fw.h | 1 | ||||
-rw-r--r-- | drivers/net/mlx4/main.c | 211 | ||||
-rw-r--r-- | drivers/net/mlx4/mlx4.h | 6 | ||||
-rw-r--r-- | drivers/net/mlx4/port.c | 23 | ||||
-rw-r--r-- | include/linux/mlx4/device.h | 14 |
9 files changed, 266 insertions, 11 deletions
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c index cdca3a511e1c..606f1e2ef284 100644 --- a/drivers/infiniband/hw/mlx4/mad.c +++ b/drivers/infiniband/hw/mlx4/mad.c | |||
@@ -298,7 +298,7 @@ int mlx4_ib_mad_init(struct mlx4_ib_dev *dev) | |||
298 | int p, q; | 298 | int p, q; |
299 | int ret; | 299 | int ret; |
300 | 300 | ||
301 | for (p = 0; p < dev->dev->caps.num_ports; ++p) | 301 | for (p = 0; p < dev->num_ports; ++p) |
302 | for (q = 0; q <= 1; ++q) { | 302 | for (q = 0; q <= 1; ++q) { |
303 | agent = ib_register_mad_agent(&dev->ib_dev, p + 1, | 303 | agent = ib_register_mad_agent(&dev->ib_dev, p + 1, |
304 | q ? IB_QPT_GSI : IB_QPT_SMI, | 304 | q ? IB_QPT_GSI : IB_QPT_SMI, |
@@ -314,7 +314,7 @@ int mlx4_ib_mad_init(struct mlx4_ib_dev *dev) | |||
314 | return 0; | 314 | return 0; |
315 | 315 | ||
316 | err: | 316 | err: |
317 | for (p = 0; p < dev->dev->caps.num_ports; ++p) | 317 | for (p = 0; p < dev->num_ports; ++p) |
318 | for (q = 0; q <= 1; ++q) | 318 | for (q = 0; q <= 1; ++q) |
319 | if (dev->send_agent[p][q]) | 319 | if (dev->send_agent[p][q]) |
320 | ib_unregister_mad_agent(dev->send_agent[p][q]); | 320 | ib_unregister_mad_agent(dev->send_agent[p][q]); |
@@ -327,7 +327,7 @@ void mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev) | |||
327 | struct ib_mad_agent *agent; | 327 | struct ib_mad_agent *agent; |
328 | int p, q; | 328 | int p, q; |
329 | 329 | ||
330 | for (p = 0; p < dev->dev->caps.num_ports; ++p) { | 330 | for (p = 0; p < dev->num_ports; ++p) { |
331 | for (q = 0; q <= 1; ++q) { | 331 | for (q = 0; q <= 1; ++q) { |
332 | agent = dev->send_agent[p][q]; | 332 | agent = dev->send_agent[p][q]; |
333 | dev->send_agent[p][q] = NULL; | 333 | dev->send_agent[p][q] = NULL; |
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index a3c2851c0545..2e80f8f47b02 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c | |||
@@ -574,7 +574,10 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) | |||
574 | ibdev->ib_dev.owner = THIS_MODULE; | 574 | ibdev->ib_dev.owner = THIS_MODULE; |
575 | ibdev->ib_dev.node_type = RDMA_NODE_IB_CA; | 575 | ibdev->ib_dev.node_type = RDMA_NODE_IB_CA; |
576 | ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey; | 576 | ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey; |
577 | ibdev->ib_dev.phys_port_cnt = dev->caps.num_ports; | 577 | ibdev->num_ports = 0; |
578 | mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB) | ||
579 | ibdev->num_ports++; | ||
580 | ibdev->ib_dev.phys_port_cnt = ibdev->num_ports; | ||
578 | ibdev->ib_dev.num_comp_vectors = 1; | 581 | ibdev->ib_dev.num_comp_vectors = 1; |
579 | ibdev->ib_dev.dma_device = &dev->pdev->dev; | 582 | ibdev->ib_dev.dma_device = &dev->pdev->dev; |
580 | 583 | ||
@@ -691,7 +694,7 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr) | |||
691 | struct mlx4_ib_dev *ibdev = ibdev_ptr; | 694 | struct mlx4_ib_dev *ibdev = ibdev_ptr; |
692 | int p; | 695 | int p; |
693 | 696 | ||
694 | for (p = 1; p <= dev->caps.num_ports; ++p) | 697 | for (p = 1; p <= ibdev->num_ports; ++p) |
695 | mlx4_CLOSE_PORT(dev, p); | 698 | mlx4_CLOSE_PORT(dev, p); |
696 | 699 | ||
697 | mlx4_ib_mad_cleanup(ibdev); | 700 | mlx4_ib_mad_cleanup(ibdev); |
@@ -706,6 +709,10 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr, | |||
706 | enum mlx4_dev_event event, int port) | 709 | enum mlx4_dev_event event, int port) |
707 | { | 710 | { |
708 | struct ib_event ibev; | 711 | struct ib_event ibev; |
712 | struct mlx4_ib_dev *ibdev = to_mdev((struct ib_device *) ibdev_ptr); | ||
713 | |||
714 | if (port > ibdev->num_ports) | ||
715 | return; | ||
709 | 716 | ||
710 | switch (event) { | 717 | switch (event) { |
711 | case MLX4_DEV_EVENT_PORT_UP: | 718 | case MLX4_DEV_EVENT_PORT_UP: |
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h index 6e2b0dc21b61..9974e886b8de 100644 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h | |||
@@ -162,6 +162,7 @@ struct mlx4_ib_ah { | |||
162 | struct mlx4_ib_dev { | 162 | struct mlx4_ib_dev { |
163 | struct ib_device ib_dev; | 163 | struct ib_device ib_dev; |
164 | struct mlx4_dev *dev; | 164 | struct mlx4_dev *dev; |
165 | int num_ports; | ||
165 | void __iomem *uar_map; | 166 | void __iomem *uar_map; |
166 | 167 | ||
167 | struct mlx4_uar priv_uar; | 168 | struct mlx4_uar priv_uar; |
diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c index 8d402db9a03d..be09fdb79cb8 100644 --- a/drivers/net/mlx4/fw.c +++ b/drivers/net/mlx4/fw.c | |||
@@ -88,6 +88,7 @@ static void dump_dev_cap_flags(struct mlx4_dev *dev, u32 flags) | |||
88 | [ 8] = "P_Key violation counter", | 88 | [ 8] = "P_Key violation counter", |
89 | [ 9] = "Q_Key violation counter", | 89 | [ 9] = "Q_Key violation counter", |
90 | [10] = "VMM", | 90 | [10] = "VMM", |
91 | [12] = "DPDP", | ||
91 | [16] = "MW support", | 92 | [16] = "MW support", |
92 | [17] = "APM support", | 93 | [17] = "APM support", |
93 | [18] = "Atomic ops support", | 94 | [18] = "Atomic ops support", |
@@ -354,6 +355,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
354 | dev_cap->max_pkeys[i] = 1 << (field & 0xf); | 355 | dev_cap->max_pkeys[i] = 1 << (field & 0xf); |
355 | } | 356 | } |
356 | } else { | 357 | } else { |
358 | #define QUERY_PORT_SUPPORTED_TYPE_OFFSET 0x00 | ||
357 | #define QUERY_PORT_MTU_OFFSET 0x01 | 359 | #define QUERY_PORT_MTU_OFFSET 0x01 |
358 | #define QUERY_PORT_ETH_MTU_OFFSET 0x02 | 360 | #define QUERY_PORT_ETH_MTU_OFFSET 0x02 |
359 | #define QUERY_PORT_WIDTH_OFFSET 0x06 | 361 | #define QUERY_PORT_WIDTH_OFFSET 0x06 |
@@ -368,6 +370,8 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
368 | if (err) | 370 | if (err) |
369 | goto out; | 371 | goto out; |
370 | 372 | ||
373 | MLX4_GET(field, outbox, QUERY_PORT_SUPPORTED_TYPE_OFFSET); | ||
374 | dev_cap->supported_port_types[i] = field & 3; | ||
371 | MLX4_GET(field, outbox, QUERY_PORT_MTU_OFFSET); | 375 | MLX4_GET(field, outbox, QUERY_PORT_MTU_OFFSET); |
372 | dev_cap->ib_mtu[i] = field & 0xf; | 376 | dev_cap->ib_mtu[i] = field & 0xf; |
373 | MLX4_GET(field, outbox, QUERY_PORT_WIDTH_OFFSET); | 377 | MLX4_GET(field, outbox, QUERY_PORT_WIDTH_OFFSET); |
diff --git a/drivers/net/mlx4/fw.h b/drivers/net/mlx4/fw.h index d0913d4d262a..526d7f30c041 100644 --- a/drivers/net/mlx4/fw.h +++ b/drivers/net/mlx4/fw.h | |||
@@ -104,6 +104,7 @@ struct mlx4_dev_cap { | |||
104 | u32 reserved_lkey; | 104 | u32 reserved_lkey; |
105 | u64 max_icm_sz; | 105 | u64 max_icm_sz; |
106 | int max_gso_sz; | 106 | int max_gso_sz; |
107 | u8 supported_port_types[MLX4_MAX_PORTS + 1]; | ||
107 | u8 log_max_macs[MLX4_MAX_PORTS + 1]; | 108 | u8 log_max_macs[MLX4_MAX_PORTS + 1]; |
108 | u8 log_max_vlans[MLX4_MAX_PORTS + 1]; | 109 | u8 log_max_vlans[MLX4_MAX_PORTS + 1]; |
109 | }; | 110 | }; |
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c index 0a5c8bfb3f1f..c1d447873bf1 100644 --- a/drivers/net/mlx4/main.c +++ b/drivers/net/mlx4/main.c | |||
@@ -98,6 +98,44 @@ module_param_named(use_prio, use_prio, bool, 0444); | |||
98 | MODULE_PARM_DESC(use_prio, "Enable steering by VLAN priority on ETH ports " | 98 | MODULE_PARM_DESC(use_prio, "Enable steering by VLAN priority on ETH ports " |
99 | "(0/1, default 0)"); | 99 | "(0/1, default 0)"); |
100 | 100 | ||
101 | static int mlx4_check_port_params(struct mlx4_dev *dev, | ||
102 | enum mlx4_port_type *port_type) | ||
103 | { | ||
104 | int i; | ||
105 | |||
106 | for (i = 0; i < dev->caps.num_ports - 1; i++) { | ||
107 | if (port_type[i] != port_type[i+1] && | ||
108 | !(dev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP)) { | ||
109 | mlx4_err(dev, "Only same port types supported " | ||
110 | "on this HCA, aborting.\n"); | ||
111 | return -EINVAL; | ||
112 | } | ||
113 | } | ||
114 | if ((port_type[0] == MLX4_PORT_TYPE_ETH) && | ||
115 | (port_type[1] == MLX4_PORT_TYPE_IB)) { | ||
116 | mlx4_err(dev, "eth-ib configuration is not supported.\n"); | ||
117 | return -EINVAL; | ||
118 | } | ||
119 | |||
120 | for (i = 0; i < dev->caps.num_ports; i++) { | ||
121 | if (!(port_type[i] & dev->caps.supported_type[i+1])) { | ||
122 | mlx4_err(dev, "Requested port type for port %d is not " | ||
123 | "supported on this HCA\n", i + 1); | ||
124 | return -EINVAL; | ||
125 | } | ||
126 | } | ||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | static void mlx4_set_port_mask(struct mlx4_dev *dev) | ||
131 | { | ||
132 | int i; | ||
133 | |||
134 | dev->caps.port_mask = 0; | ||
135 | for (i = 1; i <= dev->caps.num_ports; ++i) | ||
136 | if (dev->caps.port_type[i] == MLX4_PORT_TYPE_IB) | ||
137 | dev->caps.port_mask |= 1 << (i - 1); | ||
138 | } | ||
101 | static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | 139 | static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) |
102 | { | 140 | { |
103 | int err; | 141 | int err; |
@@ -139,6 +177,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
139 | dev->caps.port_width_cap[i] = dev_cap->max_port_width[i]; | 177 | dev->caps.port_width_cap[i] = dev_cap->max_port_width[i]; |
140 | dev->caps.eth_mtu_cap[i] = dev_cap->eth_mtu[i]; | 178 | dev->caps.eth_mtu_cap[i] = dev_cap->eth_mtu[i]; |
141 | dev->caps.def_mac[i] = dev_cap->def_mac[i]; | 179 | dev->caps.def_mac[i] = dev_cap->def_mac[i]; |
180 | dev->caps.supported_type[i] = dev_cap->supported_port_types[i]; | ||
142 | } | 181 | } |
143 | 182 | ||
144 | dev->caps.num_uars = dev_cap->uar_size / PAGE_SIZE; | 183 | dev->caps.num_uars = dev_cap->uar_size / PAGE_SIZE; |
@@ -182,6 +221,11 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
182 | dev->caps.log_num_prios = use_prio ? 3 : 0; | 221 | dev->caps.log_num_prios = use_prio ? 3 : 0; |
183 | 222 | ||
184 | for (i = 1; i <= dev->caps.num_ports; ++i) { | 223 | for (i = 1; i <= dev->caps.num_ports; ++i) { |
224 | if (dev->caps.supported_type[i] != MLX4_PORT_TYPE_ETH) | ||
225 | dev->caps.port_type[i] = MLX4_PORT_TYPE_IB; | ||
226 | else | ||
227 | dev->caps.port_type[i] = MLX4_PORT_TYPE_ETH; | ||
228 | |||
185 | if (dev->caps.log_num_macs > dev_cap->log_max_macs[i]) { | 229 | if (dev->caps.log_num_macs > dev_cap->log_max_macs[i]) { |
186 | dev->caps.log_num_macs = dev_cap->log_max_macs[i]; | 230 | dev->caps.log_num_macs = dev_cap->log_max_macs[i]; |
187 | mlx4_warn(dev, "Requested number of MACs is too much " | 231 | mlx4_warn(dev, "Requested number of MACs is too much " |
@@ -196,6 +240,8 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
196 | } | 240 | } |
197 | } | 241 | } |
198 | 242 | ||
243 | mlx4_set_port_mask(dev); | ||
244 | |||
199 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps; | 245 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps; |
200 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] = | 246 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_ETH_ADDR] = |
201 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] = | 247 | dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_ADDR] = |
@@ -213,6 +259,95 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) | |||
213 | return 0; | 259 | return 0; |
214 | } | 260 | } |
215 | 261 | ||
262 | /* | ||
263 | * Change the port configuration of the device. | ||
264 | * Every user of this function must hold the port mutex. | ||
265 | */ | ||
266 | static int mlx4_change_port_types(struct mlx4_dev *dev, | ||
267 | enum mlx4_port_type *port_types) | ||
268 | { | ||
269 | int err = 0; | ||
270 | int change = 0; | ||
271 | int port; | ||
272 | |||
273 | for (port = 0; port < dev->caps.num_ports; port++) { | ||
274 | if (port_types[port] != dev->caps.port_type[port + 1]) { | ||
275 | change = 1; | ||
276 | dev->caps.port_type[port + 1] = port_types[port]; | ||
277 | } | ||
278 | } | ||
279 | if (change) { | ||
280 | mlx4_unregister_device(dev); | ||
281 | for (port = 1; port <= dev->caps.num_ports; port++) { | ||
282 | mlx4_CLOSE_PORT(dev, port); | ||
283 | err = mlx4_SET_PORT(dev, port); | ||
284 | if (err) { | ||
285 | mlx4_err(dev, "Failed to set port %d, " | ||
286 | "aborting\n", port); | ||
287 | goto out; | ||
288 | } | ||
289 | } | ||
290 | mlx4_set_port_mask(dev); | ||
291 | err = mlx4_register_device(dev); | ||
292 | } | ||
293 | |||
294 | out: | ||
295 | return err; | ||
296 | } | ||
297 | |||
298 | static ssize_t show_port_type(struct device *dev, | ||
299 | struct device_attribute *attr, | ||
300 | char *buf) | ||
301 | { | ||
302 | struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info, | ||
303 | port_attr); | ||
304 | struct mlx4_dev *mdev = info->dev; | ||
305 | |||
306 | return sprintf(buf, "%s\n", | ||
307 | mdev->caps.port_type[info->port] == MLX4_PORT_TYPE_IB ? | ||
308 | "ib" : "eth"); | ||
309 | } | ||
310 | |||
311 | static ssize_t set_port_type(struct device *dev, | ||
312 | struct device_attribute *attr, | ||
313 | const char *buf, size_t count) | ||
314 | { | ||
315 | struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info, | ||
316 | port_attr); | ||
317 | struct mlx4_dev *mdev = info->dev; | ||
318 | struct mlx4_priv *priv = mlx4_priv(mdev); | ||
319 | enum mlx4_port_type types[MLX4_MAX_PORTS]; | ||
320 | int i; | ||
321 | int err = 0; | ||
322 | |||
323 | if (!strcmp(buf, "ib\n")) | ||
324 | info->tmp_type = MLX4_PORT_TYPE_IB; | ||
325 | else if (!strcmp(buf, "eth\n")) | ||
326 | info->tmp_type = MLX4_PORT_TYPE_ETH; | ||
327 | else { | ||
328 | mlx4_err(mdev, "%s is not supported port type\n", buf); | ||
329 | return -EINVAL; | ||
330 | } | ||
331 | |||
332 | mutex_lock(&priv->port_mutex); | ||
333 | for (i = 0; i < mdev->caps.num_ports; i++) | ||
334 | types[i] = priv->port[i+1].tmp_type ? priv->port[i+1].tmp_type : | ||
335 | mdev->caps.port_type[i+1]; | ||
336 | |||
337 | err = mlx4_check_port_params(mdev, types); | ||
338 | if (err) | ||
339 | goto out; | ||
340 | |||
341 | for (i = 1; i <= mdev->caps.num_ports; i++) | ||
342 | priv->port[i].tmp_type = 0; | ||
343 | |||
344 | err = mlx4_change_port_types(mdev, types); | ||
345 | |||
346 | out: | ||
347 | mutex_unlock(&priv->port_mutex); | ||
348 | return err ? err : count; | ||
349 | } | ||
350 | |||
216 | static int mlx4_load_fw(struct mlx4_dev *dev) | 351 | static int mlx4_load_fw(struct mlx4_dev *dev) |
217 | { | 352 | { |
218 | struct mlx4_priv *priv = mlx4_priv(dev); | 353 | struct mlx4_priv *priv = mlx4_priv(dev); |
@@ -617,6 +752,7 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) | |||
617 | { | 752 | { |
618 | struct mlx4_priv *priv = mlx4_priv(dev); | 753 | struct mlx4_priv *priv = mlx4_priv(dev); |
619 | int err; | 754 | int err; |
755 | int port; | ||
620 | 756 | ||
621 | err = mlx4_init_uar_table(dev); | 757 | err = mlx4_init_uar_table(dev); |
622 | if (err) { | 758 | if (err) { |
@@ -715,8 +851,20 @@ static int mlx4_setup_hca(struct mlx4_dev *dev) | |||
715 | goto err_qp_table_free; | 851 | goto err_qp_table_free; |
716 | } | 852 | } |
717 | 853 | ||
854 | for (port = 1; port <= dev->caps.num_ports; port++) { | ||
855 | err = mlx4_SET_PORT(dev, port); | ||
856 | if (err) { | ||
857 | mlx4_err(dev, "Failed to set port %d, aborting\n", | ||
858 | port); | ||
859 | goto err_mcg_table_free; | ||
860 | } | ||
861 | } | ||
862 | |||
718 | return 0; | 863 | return 0; |
719 | 864 | ||
865 | err_mcg_table_free: | ||
866 | mlx4_cleanup_mcg_table(dev); | ||
867 | |||
720 | err_qp_table_free: | 868 | err_qp_table_free: |
721 | mlx4_cleanup_qp_table(dev); | 869 | mlx4_cleanup_qp_table(dev); |
722 | 870 | ||
@@ -780,14 +928,37 @@ no_msi: | |||
780 | priv->eq_table.eq[i].irq = dev->pdev->irq; | 928 | priv->eq_table.eq[i].irq = dev->pdev->irq; |
781 | } | 929 | } |
782 | 930 | ||
783 | static void mlx4_init_port_info(struct mlx4_dev *dev, int port) | 931 | static int mlx4_init_port_info(struct mlx4_dev *dev, int port) |
784 | { | 932 | { |
785 | struct mlx4_port_info *info = &mlx4_priv(dev)->port[port]; | 933 | struct mlx4_port_info *info = &mlx4_priv(dev)->port[port]; |
934 | int err = 0; | ||
786 | 935 | ||
787 | info->dev = dev; | 936 | info->dev = dev; |
788 | info->port = port; | 937 | info->port = port; |
789 | mlx4_init_mac_table(dev, &info->mac_table); | 938 | mlx4_init_mac_table(dev, &info->mac_table); |
790 | mlx4_init_vlan_table(dev, &info->vlan_table); | 939 | mlx4_init_vlan_table(dev, &info->vlan_table); |
940 | |||
941 | sprintf(info->dev_name, "mlx4_port%d", port); | ||
942 | info->port_attr.attr.name = info->dev_name; | ||
943 | info->port_attr.attr.mode = S_IRUGO | S_IWUSR; | ||
944 | info->port_attr.show = show_port_type; | ||
945 | info->port_attr.store = set_port_type; | ||
946 | |||
947 | err = device_create_file(&dev->pdev->dev, &info->port_attr); | ||
948 | if (err) { | ||
949 | mlx4_err(dev, "Failed to create file for port %d\n", port); | ||
950 | info->port = -1; | ||
951 | } | ||
952 | |||
953 | return err; | ||
954 | } | ||
955 | |||
956 | static void mlx4_cleanup_port_info(struct mlx4_port_info *info) | ||
957 | { | ||
958 | if (info->port < 0) | ||
959 | return; | ||
960 | |||
961 | device_remove_file(&info->dev->pdev->dev, &info->port_attr); | ||
791 | } | 962 | } |
792 | 963 | ||
793 | static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 964 | static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
@@ -870,6 +1041,8 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
870 | INIT_LIST_HEAD(&priv->ctx_list); | 1041 | INIT_LIST_HEAD(&priv->ctx_list); |
871 | spin_lock_init(&priv->ctx_lock); | 1042 | spin_lock_init(&priv->ctx_lock); |
872 | 1043 | ||
1044 | mutex_init(&priv->port_mutex); | ||
1045 | |||
873 | INIT_LIST_HEAD(&priv->pgdir_list); | 1046 | INIT_LIST_HEAD(&priv->pgdir_list); |
874 | mutex_init(&priv->pgdir_mutex); | 1047 | mutex_init(&priv->pgdir_mutex); |
875 | 1048 | ||
@@ -905,18 +1078,24 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
905 | if (err) | 1078 | if (err) |
906 | goto err_close; | 1079 | goto err_close; |
907 | 1080 | ||
908 | for (port = 1; port <= dev->caps.num_ports; port++) | 1081 | for (port = 1; port <= dev->caps.num_ports; port++) { |
909 | mlx4_init_port_info(dev, port); | 1082 | err = mlx4_init_port_info(dev, port); |
1083 | if (err) | ||
1084 | goto err_port; | ||
1085 | } | ||
910 | 1086 | ||
911 | err = mlx4_register_device(dev); | 1087 | err = mlx4_register_device(dev); |
912 | if (err) | 1088 | if (err) |
913 | goto err_cleanup; | 1089 | goto err_port; |
914 | 1090 | ||
915 | pci_set_drvdata(pdev, dev); | 1091 | pci_set_drvdata(pdev, dev); |
916 | 1092 | ||
917 | return 0; | 1093 | return 0; |
918 | 1094 | ||
919 | err_cleanup: | 1095 | err_port: |
1096 | for (port = 1; port <= dev->caps.num_ports; port++) | ||
1097 | mlx4_cleanup_port_info(&priv->port[port]); | ||
1098 | |||
920 | mlx4_cleanup_mcg_table(dev); | 1099 | mlx4_cleanup_mcg_table(dev); |
921 | mlx4_cleanup_qp_table(dev); | 1100 | mlx4_cleanup_qp_table(dev); |
922 | mlx4_cleanup_srq_table(dev); | 1101 | mlx4_cleanup_srq_table(dev); |
@@ -973,8 +1152,10 @@ static void mlx4_remove_one(struct pci_dev *pdev) | |||
973 | if (dev) { | 1152 | if (dev) { |
974 | mlx4_unregister_device(dev); | 1153 | mlx4_unregister_device(dev); |
975 | 1154 | ||
976 | for (p = 1; p <= dev->caps.num_ports; ++p) | 1155 | for (p = 1; p <= dev->caps.num_ports; p++) { |
1156 | mlx4_cleanup_port_info(&priv->port[p]); | ||
977 | mlx4_CLOSE_PORT(dev, p); | 1157 | mlx4_CLOSE_PORT(dev, p); |
1158 | } | ||
978 | 1159 | ||
979 | mlx4_cleanup_mcg_table(dev); | 1160 | mlx4_cleanup_mcg_table(dev); |
980 | mlx4_cleanup_qp_table(dev); | 1161 | mlx4_cleanup_qp_table(dev); |
@@ -1026,10 +1207,28 @@ static struct pci_driver mlx4_driver = { | |||
1026 | .remove = __devexit_p(mlx4_remove_one) | 1207 | .remove = __devexit_p(mlx4_remove_one) |
1027 | }; | 1208 | }; |
1028 | 1209 | ||
1210 | static int __init mlx4_verify_params(void) | ||
1211 | { | ||
1212 | if ((log_num_mac < 0) || (log_num_mac > 7)) { | ||
1213 | printk(KERN_WARNING "mlx4_core: bad num_mac: %d\n", log_num_mac); | ||
1214 | return -1; | ||
1215 | } | ||
1216 | |||
1217 | if ((log_num_vlan < 0) || (log_num_vlan > 7)) { | ||
1218 | printk(KERN_WARNING "mlx4_core: bad num_vlan: %d\n", log_num_vlan); | ||
1219 | return -1; | ||
1220 | } | ||
1221 | |||
1222 | return 0; | ||
1223 | } | ||
1224 | |||
1029 | static int __init mlx4_init(void) | 1225 | static int __init mlx4_init(void) |
1030 | { | 1226 | { |
1031 | int ret; | 1227 | int ret; |
1032 | 1228 | ||
1229 | if (mlx4_verify_params()) | ||
1230 | return -EINVAL; | ||
1231 | |||
1033 | ret = mlx4_catas_init(); | 1232 | ret = mlx4_catas_init(); |
1034 | if (ret) | 1233 | if (ret) |
1035 | return ret; | 1234 | return ret; |
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 23309f381ee3..fa431fad0eec 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h | |||
@@ -277,6 +277,9 @@ struct mlx4_vlan_table { | |||
277 | struct mlx4_port_info { | 277 | struct mlx4_port_info { |
278 | struct mlx4_dev *dev; | 278 | struct mlx4_dev *dev; |
279 | int port; | 279 | int port; |
280 | char dev_name[16]; | ||
281 | struct device_attribute port_attr; | ||
282 | enum mlx4_port_type tmp_type; | ||
280 | struct mlx4_mac_table mac_table; | 283 | struct mlx4_mac_table mac_table; |
281 | struct mlx4_vlan_table vlan_table; | 284 | struct mlx4_vlan_table vlan_table; |
282 | }; | 285 | }; |
@@ -310,6 +313,7 @@ struct mlx4_priv { | |||
310 | struct mlx4_uar driver_uar; | 313 | struct mlx4_uar driver_uar; |
311 | void __iomem *kar; | 314 | void __iomem *kar; |
312 | struct mlx4_port_info port[MLX4_MAX_PORTS + 1]; | 315 | struct mlx4_port_info port[MLX4_MAX_PORTS + 1]; |
316 | struct mutex port_mutex; | ||
313 | }; | 317 | }; |
314 | 318 | ||
315 | static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev) | 319 | static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev) |
@@ -383,4 +387,6 @@ void mlx4_handle_catas_err(struct mlx4_dev *dev); | |||
383 | void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table); | 387 | void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table); |
384 | void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table); | 388 | void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table); |
385 | 389 | ||
390 | int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port); | ||
391 | |||
386 | #endif /* MLX4_H */ | 392 | #endif /* MLX4_H */ |
diff --git a/drivers/net/mlx4/port.c b/drivers/net/mlx4/port.c index 8644f3d978ee..e2fdab42c4ce 100644 --- a/drivers/net/mlx4/port.c +++ b/drivers/net/mlx4/port.c | |||
@@ -257,3 +257,26 @@ out: | |||
257 | mutex_unlock(&table->mutex); | 257 | mutex_unlock(&table->mutex); |
258 | } | 258 | } |
259 | EXPORT_SYMBOL_GPL(mlx4_unregister_vlan); | 259 | EXPORT_SYMBOL_GPL(mlx4_unregister_vlan); |
260 | |||
261 | int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port) | ||
262 | { | ||
263 | struct mlx4_cmd_mailbox *mailbox; | ||
264 | int err; | ||
265 | u8 is_eth = dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH; | ||
266 | |||
267 | mailbox = mlx4_alloc_cmd_mailbox(dev); | ||
268 | if (IS_ERR(mailbox)) | ||
269 | return PTR_ERR(mailbox); | ||
270 | |||
271 | memset(mailbox->buf, 0, 256); | ||
272 | if (is_eth) { | ||
273 | ((u8 *) mailbox->buf)[3] = 6; | ||
274 | ((__be16 *) mailbox->buf)[4] = cpu_to_be16(1 << 15); | ||
275 | ((__be16 *) mailbox->buf)[6] = cpu_to_be16(1 << 15); | ||
276 | } | ||
277 | err = mlx4_cmd(dev, mailbox->dma, port, is_eth, MLX4_CMD_SET_PORT, | ||
278 | MLX4_CMD_TIME_CLASS_B); | ||
279 | |||
280 | mlx4_free_cmd_mailbox(dev, mailbox); | ||
281 | return err; | ||
282 | } | ||
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index 1951fe70a251..bd9977b89490 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h | |||
@@ -60,6 +60,7 @@ enum { | |||
60 | MLX4_DEV_CAP_FLAG_IPOIB_CSUM = 1 << 7, | 60 | MLX4_DEV_CAP_FLAG_IPOIB_CSUM = 1 << 7, |
61 | MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1 << 8, | 61 | MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1 << 8, |
62 | MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1 << 9, | 62 | MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1 << 9, |
63 | MLX4_DEV_CAP_FLAG_DPDP = 1 << 12, | ||
63 | MLX4_DEV_CAP_FLAG_MEM_WINDOW = 1 << 16, | 64 | MLX4_DEV_CAP_FLAG_MEM_WINDOW = 1 << 16, |
64 | MLX4_DEV_CAP_FLAG_APM = 1 << 17, | 65 | MLX4_DEV_CAP_FLAG_APM = 1 << 17, |
65 | MLX4_DEV_CAP_FLAG_ATOMIC = 1 << 18, | 66 | MLX4_DEV_CAP_FLAG_ATOMIC = 1 << 18, |
@@ -153,6 +154,11 @@ enum mlx4_qp_region { | |||
153 | MLX4_NUM_QP_REGION | 154 | MLX4_NUM_QP_REGION |
154 | }; | 155 | }; |
155 | 156 | ||
157 | enum mlx4_port_type { | ||
158 | MLX4_PORT_TYPE_IB = 1 << 0, | ||
159 | MLX4_PORT_TYPE_ETH = 1 << 1, | ||
160 | }; | ||
161 | |||
156 | enum mlx4_special_vlan_idx { | 162 | enum mlx4_special_vlan_idx { |
157 | MLX4_NO_VLAN_IDX = 0, | 163 | MLX4_NO_VLAN_IDX = 0, |
158 | MLX4_VLAN_MISS_IDX, | 164 | MLX4_VLAN_MISS_IDX, |
@@ -226,6 +232,9 @@ struct mlx4_caps { | |||
226 | int log_num_macs; | 232 | int log_num_macs; |
227 | int log_num_vlans; | 233 | int log_num_vlans; |
228 | int log_num_prios; | 234 | int log_num_prios; |
235 | enum mlx4_port_type port_type[MLX4_MAX_PORTS + 1]; | ||
236 | u8 supported_type[MLX4_MAX_PORTS + 1]; | ||
237 | u32 port_mask; | ||
229 | }; | 238 | }; |
230 | 239 | ||
231 | struct mlx4_buf_list { | 240 | struct mlx4_buf_list { |
@@ -380,6 +389,11 @@ struct mlx4_init_port_param { | |||
380 | u64 si_guid; | 389 | u64 si_guid; |
381 | }; | 390 | }; |
382 | 391 | ||
392 | #define mlx4_foreach_port(port, dev, type) \ | ||
393 | for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \ | ||
394 | if (((type) == MLX4_PORT_TYPE_IB ? (dev)->caps.port_mask : \ | ||
395 | ~(dev)->caps.port_mask) & 1 << ((port) - 1)) | ||
396 | |||
383 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, | 397 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, |
384 | struct mlx4_buf *buf); | 398 | struct mlx4_buf *buf); |
385 | void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); | 399 | void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); |