diff options
author | David S. Miller <davem@davemloft.net> | 2017-06-04 23:49:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-04 23:49:49 -0400 |
commit | aae1a2ce1416fa79213bd765cee5b961540265b3 (patch) | |
tree | 1746950039e57e11c44674b289d216f469b7b006 | |
parent | a4e1ce24f7e2dc59d2bba5c11487778030f9d5bf (diff) | |
parent | de5ed99e9777a487da4ad9c58e409ed26b640d9e (diff) |
Merge branch 'mlxsw-Minor-cleanup'
Jiri Pirko says:
====================
mlxsw: Minor cleanup
Fix small issues I noticed during the refactoring.
First patch adds file name comments in the header file to make it clear
what goes where. Second patch fixes a typo and third patch simply aligns
RIF index allocation with similar allocations in the driver.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/reg.h | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 47 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 24 |
4 files changed, 41 insertions, 38 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index 182150afd5ad..157b9b6f8485 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h | |||
@@ -958,7 +958,7 @@ enum mlxsw_flood_table_type { | |||
958 | MLXSW_REG_SFGC_TABLE_TYPE_VID = 1, | 958 | MLXSW_REG_SFGC_TABLE_TYPE_VID = 1, |
959 | MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2, | 959 | MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2, |
960 | MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0, | 960 | MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0, |
961 | MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST = 3, | 961 | MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3, |
962 | MLXSW_REG_SFGC_TABLE_TYPE_FID = 4, | 962 | MLXSW_REG_SFGC_TABLE_TYPE_FID = 4, |
963 | }; | 963 | }; |
964 | 964 | ||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 1a834109bda1..99760fd55ba1 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h | |||
@@ -233,12 +233,6 @@ struct mlxsw_sp_port { | |||
233 | struct list_head vlans_list; | 233 | struct list_head vlans_list; |
234 | }; | 234 | }; |
235 | 235 | ||
236 | bool mlxsw_sp_port_dev_check(const struct net_device *dev); | ||
237 | struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev); | ||
238 | struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); | ||
239 | struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev); | ||
240 | void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port); | ||
241 | |||
242 | static inline bool | 236 | static inline bool |
243 | mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) | 237 | mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) |
244 | { | 238 | { |
@@ -278,6 +272,7 @@ enum mlxsw_sp_flood_type { | |||
278 | MLXSW_SP_FLOOD_TYPE_MC, | 272 | MLXSW_SP_FLOOD_TYPE_MC, |
279 | }; | 273 | }; |
280 | 274 | ||
275 | /* spectrum_buffers.c */ | ||
281 | int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); | 276 | int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); |
282 | void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); | 277 | void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); |
283 | int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); | 278 | int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); |
@@ -315,12 +310,11 @@ int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port, | |||
315 | u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); | 310 | u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); |
316 | u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); | 311 | u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); |
317 | 312 | ||
313 | /* spectrum_switchdev.c */ | ||
318 | int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); | 314 | int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); |
319 | void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); | 315 | void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); |
320 | void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port); | 316 | void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port); |
321 | void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port); | 317 | void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port); |
322 | int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, | ||
323 | u16 vid_end, bool is_member, bool untagged); | ||
324 | int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, | 318 | int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, |
325 | bool adding); | 319 | bool adding); |
326 | void | 320 | void |
@@ -332,6 +326,7 @@ void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, | |||
332 | struct net_device *brport_dev, | 326 | struct net_device *brport_dev, |
333 | struct net_device *br_dev); | 327 | struct net_device *br_dev); |
334 | 328 | ||
329 | /* spectrum.c */ | ||
335 | int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, | 330 | int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, |
336 | enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, | 331 | enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, |
337 | bool dwrr, u8 dwrr_weight); | 332 | bool dwrr, u8 dwrr_weight); |
@@ -352,24 +347,35 @@ int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); | |||
352 | struct mlxsw_sp_port_vlan * | 347 | struct mlxsw_sp_port_vlan * |
353 | mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); | 348 | mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
354 | void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); | 349 | void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); |
350 | int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, | ||
351 | u16 vid_end, bool is_member, bool untagged); | ||
352 | int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, | ||
353 | unsigned int counter_index, u64 *packets, | ||
354 | u64 *bytes); | ||
355 | int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, | ||
356 | unsigned int *p_counter_index); | ||
357 | void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, | ||
358 | unsigned int counter_index); | ||
359 | bool mlxsw_sp_port_dev_check(const struct net_device *dev); | ||
360 | struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev); | ||
361 | struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); | ||
362 | struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev); | ||
363 | void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port); | ||
355 | 364 | ||
365 | /* spectrum_dcb.c */ | ||
356 | #ifdef CONFIG_MLXSW_SPECTRUM_DCB | 366 | #ifdef CONFIG_MLXSW_SPECTRUM_DCB |
357 | |||
358 | int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); | 367 | int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); |
359 | void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); | 368 | void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); |
360 | |||
361 | #else | 369 | #else |
362 | |||
363 | static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) | 370 | static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) |
364 | { | 371 | { |
365 | return 0; | 372 | return 0; |
366 | } | 373 | } |
367 | |||
368 | static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) | 374 | static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) |
369 | {} | 375 | {} |
370 | |||
371 | #endif | 376 | #endif |
372 | 377 | ||
378 | /* spectrum_router.c */ | ||
373 | int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp); | 379 | int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp); |
374 | void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); | 380 | void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); |
375 | int mlxsw_sp_router_netevent_event(struct notifier_block *unused, | 381 | int mlxsw_sp_router_netevent_event(struct notifier_block *unused, |
@@ -383,12 +389,11 @@ void | |||
383 | mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); | 389 | mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); |
384 | void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif); | 390 | void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif); |
385 | 391 | ||
392 | /* spectrum_kvdl.c */ | ||
386 | int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count, | 393 | int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count, |
387 | u32 *p_entry_index); | 394 | u32 *p_entry_index); |
388 | void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index); | 395 | void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index); |
389 | 396 | ||
390 | struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); | ||
391 | |||
392 | struct mlxsw_sp_acl_rule_info { | 397 | struct mlxsw_sp_acl_rule_info { |
393 | unsigned int priority; | 398 | unsigned int priority; |
394 | struct mlxsw_afk_element_values values; | 399 | struct mlxsw_afk_element_values values; |
@@ -429,6 +434,8 @@ struct mlxsw_sp_acl_ops { | |||
429 | 434 | ||
430 | struct mlxsw_sp_acl_ruleset; | 435 | struct mlxsw_sp_acl_ruleset; |
431 | 436 | ||
437 | /* spectrum_acl.c */ | ||
438 | struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); | ||
432 | struct mlxsw_sp_acl_ruleset * | 439 | struct mlxsw_sp_acl_ruleset * |
433 | mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, | 440 | mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, |
434 | struct net_device *dev, bool ingress, | 441 | struct net_device *dev, bool ingress, |
@@ -492,22 +499,18 @@ struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp); | |||
492 | int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); | 499 | int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); |
493 | void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); | 500 | void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); |
494 | 501 | ||
502 | /* spectrum_acl_tcam.c */ | ||
495 | extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops; | 503 | extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops; |
496 | 504 | ||
505 | /* spectrum_flower.c */ | ||
497 | int mlxsw_sp_flower_replace(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, | 506 | int mlxsw_sp_flower_replace(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, |
498 | __be16 protocol, struct tc_cls_flower_offload *f); | 507 | __be16 protocol, struct tc_cls_flower_offload *f); |
499 | void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, | 508 | void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, |
500 | struct tc_cls_flower_offload *f); | 509 | struct tc_cls_flower_offload *f); |
501 | int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, | 510 | int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, |
502 | struct tc_cls_flower_offload *f); | 511 | struct tc_cls_flower_offload *f); |
503 | int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, | ||
504 | unsigned int counter_index, u64 *packets, | ||
505 | u64 *bytes); | ||
506 | int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, | ||
507 | unsigned int *p_counter_index); | ||
508 | void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, | ||
509 | unsigned int counter_index); | ||
510 | 512 | ||
513 | /* spectrum_fid.c */ | ||
511 | int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, | 514 | int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, |
512 | enum mlxsw_sp_flood_type packet_type, u8 local_port, | 515 | enum mlxsw_sp_flood_type packet_type, u8 local_port, |
513 | bool member); | 516 | bool member); |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c index c7590aea1aee..6afbe9ec64e2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c | |||
@@ -373,19 +373,19 @@ static const struct mlxsw_sp_flood_table mlxsw_sp_fid_8021q_flood_tables[] = { | |||
373 | { | 373 | { |
374 | .packet_type = MLXSW_SP_FLOOD_TYPE_UC, | 374 | .packet_type = MLXSW_SP_FLOOD_TYPE_UC, |
375 | .bridge_type = MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID, | 375 | .bridge_type = MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID, |
376 | .table_type = MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST, | 376 | .table_type = MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET, |
377 | .table_index = 0, | 377 | .table_index = 0, |
378 | }, | 378 | }, |
379 | { | 379 | { |
380 | .packet_type = MLXSW_SP_FLOOD_TYPE_MC, | 380 | .packet_type = MLXSW_SP_FLOOD_TYPE_MC, |
381 | .bridge_type = MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID, | 381 | .bridge_type = MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID, |
382 | .table_type = MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST, | 382 | .table_type = MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET, |
383 | .table_index = 1, | 383 | .table_index = 1, |
384 | }, | 384 | }, |
385 | { | 385 | { |
386 | .packet_type = MLXSW_SP_FLOOD_TYPE_BC, | 386 | .packet_type = MLXSW_SP_FLOOD_TYPE_BC, |
387 | .bridge_type = MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID, | 387 | .bridge_type = MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID, |
388 | .table_type = MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST, | 388 | .table_type = MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET, |
389 | .table_index = 2, | 389 | .table_index = 2, |
390 | }, | 390 | }, |
391 | }; | 391 | }; |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index a4272c351e3a..20061058801e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | |||
@@ -2979,16 +2979,18 @@ mlxsw_sp_dev_rif_type(const struct mlxsw_sp *mlxsw_sp, | |||
2979 | return mlxsw_sp_fid_type_rif_type(mlxsw_sp, type); | 2979 | return mlxsw_sp_fid_type_rif_type(mlxsw_sp, type); |
2980 | } | 2980 | } |
2981 | 2981 | ||
2982 | #define MLXSW_SP_INVALID_INDEX_RIF 0xffff | 2982 | static int mlxsw_sp_rif_index_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_rif_index) |
2983 | static int mlxsw_sp_avail_rif_get(struct mlxsw_sp *mlxsw_sp) | ||
2984 | { | 2983 | { |
2985 | int i; | 2984 | int i; |
2986 | 2985 | ||
2987 | for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) | 2986 | for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) { |
2988 | if (!mlxsw_sp->router->rifs[i]) | 2987 | if (!mlxsw_sp->router->rifs[i]) { |
2989 | return i; | 2988 | *p_rif_index = i; |
2989 | return 0; | ||
2990 | } | ||
2991 | } | ||
2990 | 2992 | ||
2991 | return MLXSW_SP_INVALID_INDEX_RIF; | 2993 | return -ENOBUFS; |
2992 | } | 2994 | } |
2993 | 2995 | ||
2994 | static struct mlxsw_sp_rif *mlxsw_sp_rif_alloc(size_t rif_size, u16 rif_index, | 2996 | static struct mlxsw_sp_rif *mlxsw_sp_rif_alloc(size_t rif_size, u16 rif_index, |
@@ -3048,11 +3050,9 @@ mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp, | |||
3048 | if (IS_ERR(vr)) | 3050 | if (IS_ERR(vr)) |
3049 | return ERR_CAST(vr); | 3051 | return ERR_CAST(vr); |
3050 | 3052 | ||
3051 | rif_index = mlxsw_sp_avail_rif_get(mlxsw_sp); | 3053 | err = mlxsw_sp_rif_index_alloc(mlxsw_sp, &rif_index); |
3052 | if (rif_index == MLXSW_SP_INVALID_INDEX_RIF) { | 3054 | if (err) |
3053 | err = -ERANGE; | 3055 | goto err_rif_index_alloc; |
3054 | goto err_avail_rif_get; | ||
3055 | } | ||
3056 | 3056 | ||
3057 | rif = mlxsw_sp_rif_alloc(ops->rif_size, rif_index, vr->id, params->dev); | 3057 | rif = mlxsw_sp_rif_alloc(ops->rif_size, rif_index, vr->id, params->dev); |
3058 | if (!rif) { | 3058 | if (!rif) { |
@@ -3095,7 +3095,7 @@ err_configure: | |||
3095 | err_fid_get: | 3095 | err_fid_get: |
3096 | kfree(rif); | 3096 | kfree(rif); |
3097 | err_rif_alloc: | 3097 | err_rif_alloc: |
3098 | err_avail_rif_get: | 3098 | err_rif_index_alloc: |
3099 | mlxsw_sp_vr_put(vr); | 3099 | mlxsw_sp_vr_put(vr); |
3100 | return ERR_PTR(err); | 3100 | return ERR_PTR(err); |
3101 | } | 3101 | } |