|
1 | 1 | /*
|
2 | 2 | * drivers/net/ethernet/mellanox/mlxsw/spectrum.h
|
3 |
| - * Copyright (c) 2015 Mellanox Technologies. All rights reserved. |
4 |
| - * Copyright (c) 2015 Jiri Pirko <[email protected]> |
| 3 | + * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved. |
| 4 | + * Copyright (c) 2015-2017 Jiri Pirko <[email protected]> |
5 | 5 | * Copyright (c) 2015 Ido Schimmel <[email protected]>
|
6 | 6 | * Copyright (c) 2015 Elad Raz <[email protected]>
|
7 | 7 | *
|
|
50 | 50 |
|
51 | 51 | #include "port.h"
|
52 | 52 | #include "core.h"
|
| 53 | +#include "core_acl_flex_keys.h" |
| 54 | +#include "core_acl_flex_actions.h" |
53 | 55 |
|
54 | 56 | #define MLXSW_SP_VFID_BASE VLAN_N_VID
|
55 | 57 | #define MLXSW_SP_VFID_MAX 6656 /* Bridged VLAN interfaces */
|
@@ -262,6 +264,8 @@ struct mlxsw_sp_router {
|
262 | 264 | bool aborted;
|
263 | 265 | };
|
264 | 266 |
|
| 267 | +struct mlxsw_sp_acl; |
| 268 | + |
265 | 269 | struct mlxsw_sp {
|
266 | 270 | struct {
|
267 | 271 | struct list_head list;
|
@@ -291,6 +295,7 @@ struct mlxsw_sp {
|
291 | 295 | u8 port_to_module[MLXSW_PORT_MAX_PORTS];
|
292 | 296 | struct mlxsw_sp_sb sb;
|
293 | 297 | struct mlxsw_sp_router router;
|
| 298 | + struct mlxsw_sp_acl *acl; |
294 | 299 | struct {
|
295 | 300 | DECLARE_BITMAP(usage, MLXSW_SP_KVD_LINEAR_SIZE);
|
296 | 301 | } kvdl;
|
@@ -373,6 +378,7 @@ struct mlxsw_sp_port {
|
373 | 378 | struct mlxsw_sp_port_sample *sample;
|
374 | 379 | };
|
375 | 380 |
|
| 381 | +bool mlxsw_sp_port_dev_check(const struct net_device *dev); |
376 | 382 | struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev);
|
377 | 383 | void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port);
|
378 | 384 |
|
@@ -602,4 +608,94 @@ int mlxsw_sp_router_netevent_event(struct notifier_block *unused,
|
602 | 608 | int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count);
|
603 | 609 | void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index);
|
604 | 610 |
|
| 611 | +struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); |
| 612 | + |
| 613 | +struct mlxsw_sp_acl_rule_info { |
| 614 | + unsigned int priority; |
| 615 | + struct mlxsw_afk_element_values values; |
| 616 | + struct mlxsw_afa_block *act_block; |
| 617 | +}; |
| 618 | + |
| 619 | +enum mlxsw_sp_acl_profile { |
| 620 | + MLXSW_SP_ACL_PROFILE_FLOWER, |
| 621 | +}; |
| 622 | + |
| 623 | +struct mlxsw_sp_acl_profile_ops { |
| 624 | + size_t ruleset_priv_size; |
| 625 | + int (*ruleset_add)(struct mlxsw_sp *mlxsw_sp, |
| 626 | + void *priv, void *ruleset_priv); |
| 627 | + void (*ruleset_del)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv); |
| 628 | + int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv, |
| 629 | + struct net_device *dev, bool ingress); |
| 630 | + void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv); |
| 631 | + size_t rule_priv_size; |
| 632 | + int (*rule_add)(struct mlxsw_sp *mlxsw_sp, |
| 633 | + void *ruleset_priv, void *rule_priv, |
| 634 | + struct mlxsw_sp_acl_rule_info *rulei); |
| 635 | + void (*rule_del)(struct mlxsw_sp *mlxsw_sp, void *rule_priv); |
| 636 | +}; |
| 637 | + |
| 638 | +struct mlxsw_sp_acl_ops { |
| 639 | + size_t priv_size; |
| 640 | + int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); |
| 641 | + void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); |
| 642 | + const struct mlxsw_sp_acl_profile_ops * |
| 643 | + (*profile_ops)(struct mlxsw_sp *mlxsw_sp, |
| 644 | + enum mlxsw_sp_acl_profile profile); |
| 645 | +}; |
| 646 | + |
| 647 | +struct mlxsw_sp_acl_ruleset; |
| 648 | + |
| 649 | +struct mlxsw_sp_acl_ruleset * |
| 650 | +mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, |
| 651 | + struct net_device *dev, bool ingress, |
| 652 | + enum mlxsw_sp_acl_profile profile); |
| 653 | +void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp, |
| 654 | + struct mlxsw_sp_acl_ruleset *ruleset); |
| 655 | + |
| 656 | +struct mlxsw_sp_acl_rule_info * |
| 657 | +mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl); |
| 658 | +void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei); |
| 659 | +int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); |
| 660 | +void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, |
| 661 | + unsigned int priority); |
| 662 | +void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei, |
| 663 | + enum mlxsw_afk_element element, |
| 664 | + u32 key_value, u32 mask_value); |
| 665 | +void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei, |
| 666 | + enum mlxsw_afk_element element, |
| 667 | + const char *key_value, |
| 668 | + const char *mask_value, unsigned int len); |
| 669 | +void mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei); |
| 670 | +void mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, |
| 671 | + u16 group_id); |
| 672 | +int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei); |
| 673 | +int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp, |
| 674 | + struct mlxsw_sp_acl_rule_info *rulei, |
| 675 | + struct net_device *out_dev); |
| 676 | + |
| 677 | +struct mlxsw_sp_acl_rule; |
| 678 | + |
| 679 | +struct mlxsw_sp_acl_rule * |
| 680 | +mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp, |
| 681 | + struct mlxsw_sp_acl_ruleset *ruleset, |
| 682 | + unsigned long cookie); |
| 683 | +void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp, |
| 684 | + struct mlxsw_sp_acl_rule *rule); |
| 685 | +int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp, |
| 686 | + struct mlxsw_sp_acl_rule *rule); |
| 687 | +void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp, |
| 688 | + struct mlxsw_sp_acl_rule *rule); |
| 689 | +struct mlxsw_sp_acl_rule * |
| 690 | +mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp, |
| 691 | + struct mlxsw_sp_acl_ruleset *ruleset, |
| 692 | + unsigned long cookie); |
| 693 | +struct mlxsw_sp_acl_rule_info * |
| 694 | +mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule); |
| 695 | + |
| 696 | +int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); |
| 697 | +void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); |
| 698 | + |
| 699 | +extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops; |
| 700 | + |
605 | 701 | #endif
|
0 commit comments