summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-06-04 23:49:49 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-04 23:49:49 -0400
commitaae1a2ce1416fa79213bd765cee5b961540265b3 (patch)
tree1746950039e57e11c44674b289d216f469b7b006
parenta4e1ce24f7e2dc59d2bba5c11487778030f9d5bf (diff)
parentde5ed99e9777a487da4ad9c58e409ed26b640d9e (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.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.h47
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c24
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
236bool mlxsw_sp_port_dev_check(const struct net_device *dev);
237struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
238struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
239struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
240void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
241
242static inline bool 236static inline bool
243mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) 237mlxsw_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 */
281int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); 276int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
282void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); 277void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
283int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); 278int 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,
315u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); 310u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells);
316u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); 311u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);
317 312
313/* spectrum_switchdev.c */
318int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); 314int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
319void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); 315void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
320void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port); 316void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port);
321void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port); 317void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port);
322int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
323 u16 vid_end, bool is_member, bool untagged);
324int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, 318int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
325 bool adding); 319 bool adding);
326void 320void
@@ -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 */
335int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, 330int 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);
352struct mlxsw_sp_port_vlan * 347struct mlxsw_sp_port_vlan *
353mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); 348mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
354void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 349void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
350int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
351 u16 vid_end, bool is_member, bool untagged);
352int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
353 unsigned int counter_index, u64 *packets,
354 u64 *bytes);
355int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
356 unsigned int *p_counter_index);
357void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
358 unsigned int counter_index);
359bool mlxsw_sp_port_dev_check(const struct net_device *dev);
360struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);
361struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev);
362struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
363void 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
358int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); 367int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port);
359void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); 368void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port);
360
361#else 369#else
362
363static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) 370static 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
368static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) 374static 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 */
373int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp); 379int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp);
374void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); 380void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
375int mlxsw_sp_router_netevent_event(struct notifier_block *unused, 381int mlxsw_sp_router_netevent_event(struct notifier_block *unused,
@@ -383,12 +389,11 @@ void
383mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); 389mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan);
384void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif); 390void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif);
385 391
392/* spectrum_kvdl.c */
386int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count, 393int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count,
387 u32 *p_entry_index); 394 u32 *p_entry_index);
388void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index); 395void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index);
389 396
390struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
391
392struct mlxsw_sp_acl_rule_info { 397struct 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
430struct mlxsw_sp_acl_ruleset; 435struct mlxsw_sp_acl_ruleset;
431 436
437/* spectrum_acl.c */
438struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
432struct mlxsw_sp_acl_ruleset * 439struct mlxsw_sp_acl_ruleset *
433mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, 440mlxsw_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);
492int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); 499int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
493void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); 500void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
494 501
502/* spectrum_acl_tcam.c */
495extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops; 503extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops;
496 504
505/* spectrum_flower.c */
497int mlxsw_sp_flower_replace(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, 506int 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);
499void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, 508void 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);
501int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, 510int 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);
503int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
504 unsigned int counter_index, u64 *packets,
505 u64 *bytes);
506int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
507 unsigned int *p_counter_index);
508void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
509 unsigned int counter_index);
510 512
513/* spectrum_fid.c */
511int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, 514int 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 2982static int mlxsw_sp_rif_index_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_rif_index)
2983static 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
2994static struct mlxsw_sp_rif *mlxsw_sp_rif_alloc(size_t rif_size, u16 rif_index, 2996static 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:
3095err_fid_get: 3095err_fid_get:
3096 kfree(rif); 3096 kfree(rif);
3097err_rif_alloc: 3097err_rif_alloc:
3098err_avail_rif_get: 3098err_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}