| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 79fbcc73dd52acfe8b7aa20a793ce8d60c8d3f7b Mon Sep 17 00:00:00 2001 |
| 2 | From: Yangbo Lu <yangbo.lu@nxp.com> |
| 3 | Date: Thu, 28 Nov 2019 12:10:44 -0600 |
| 4 | Subject: [PATCH] LF-368 net: mscc: ocelot: make ocelot_ace_rule support |
| 5 | multiple ports |
| 6 | |
| 7 | The ocelot_ace_rule is port specific now. Make it flexible to |
| 8 | be able to support multiple ports too. |
| 9 | |
| 10 | Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> |
| 11 | --- |
| 12 | drivers/net/ethernet/mscc/ocelot_ace.c | 14 +++++++------- |
| 13 | drivers/net/ethernet/mscc/ocelot_ace.h | 4 ++-- |
| 14 | drivers/net/ethernet/mscc/ocelot_flower.c | 8 ++++---- |
| 15 | 3 files changed, 13 insertions(+), 13 deletions(-) |
| 16 | |
| 17 | --- a/drivers/net/ethernet/mscc/ocelot_ace.c |
| 18 | +++ b/drivers/net/ethernet/mscc/ocelot_ace.c |
| 19 | @@ -352,7 +352,7 @@ static void is2_entry_set(struct ocelot |
| 20 | data.type = IS2_ACTION_TYPE_NORMAL; |
| 21 | |
| 22 | VCAP_KEY_ANY_SET(PAG); |
| 23 | - VCAP_KEY_SET(IGR_PORT_MASK, 0, ~BIT(ace->chip_port)); |
| 24 | + VCAP_KEY_SET(IGR_PORT_MASK, 0, ~ace->ingress_port_mask); |
| 25 | VCAP_KEY_BIT_SET(FIRST, OCELOT_VCAP_BIT_1); |
| 26 | VCAP_KEY_BIT_SET(HOST_MATCH, OCELOT_VCAP_BIT_ANY); |
| 27 | VCAP_KEY_BIT_SET(L2_MC, ace->dmac_mc); |
| 28 | @@ -576,7 +576,7 @@ static void is2_entry_set(struct ocelot |
| 29 | |
| 30 | static void is2_entry_get(struct ocelot_ace_rule *rule, int ix) |
| 31 | { |
| 32 | - struct ocelot *op = rule->port->ocelot; |
| 33 | + struct ocelot *op = rule->ocelot; |
| 34 | struct vcap_data data; |
| 35 | int row = (ix / 2); |
| 36 | u32 cnt; |
| 37 | @@ -655,11 +655,11 @@ int ocelot_ace_rule_offload_add(struct o |
| 38 | /* Move down the rules to make place for the new rule */ |
| 39 | for (i = acl_block->count - 1; i > index; i--) { |
| 40 | ace = ocelot_ace_rule_get_rule_index(acl_block, i); |
| 41 | - is2_entry_set(rule->port->ocelot, i, ace); |
| 42 | + is2_entry_set(rule->ocelot, i, ace); |
| 43 | } |
| 44 | |
| 45 | /* Now insert the new rule */ |
| 46 | - is2_entry_set(rule->port->ocelot, index, rule); |
| 47 | + is2_entry_set(rule->ocelot, index, rule); |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | @@ -697,11 +697,11 @@ int ocelot_ace_rule_offload_del(struct o |
| 52 | /* Move up all the blocks over the deleted rule */ |
| 53 | for (i = index; i < acl_block->count; i++) { |
| 54 | ace = ocelot_ace_rule_get_rule_index(acl_block, i); |
| 55 | - is2_entry_set(rule->port->ocelot, i, ace); |
| 56 | + is2_entry_set(rule->ocelot, i, ace); |
| 57 | } |
| 58 | |
| 59 | /* Now delete the last rule, because it is duplicated */ |
| 60 | - is2_entry_set(rule->port->ocelot, acl_block->count, &del_ace); |
| 61 | + is2_entry_set(rule->ocelot, acl_block->count, &del_ace); |
| 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | @@ -717,7 +717,7 @@ int ocelot_ace_rule_stats_update(struct |
| 66 | /* After we get the result we need to clear the counters */ |
| 67 | tmp = ocelot_ace_rule_get_rule_index(acl_block, index); |
| 68 | tmp->stats.pkts = 0; |
| 69 | - is2_entry_set(rule->port->ocelot, index, tmp); |
| 70 | + is2_entry_set(rule->ocelot, index, tmp); |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | --- a/drivers/net/ethernet/mscc/ocelot_ace.h |
| 75 | +++ b/drivers/net/ethernet/mscc/ocelot_ace.h |
| 76 | @@ -186,14 +186,14 @@ struct ocelot_ace_stats { |
| 77 | |
| 78 | struct ocelot_ace_rule { |
| 79 | struct list_head list; |
| 80 | - struct ocelot_port *port; |
| 81 | + struct ocelot *ocelot; |
| 82 | |
| 83 | u16 prio; |
| 84 | u32 id; |
| 85 | |
| 86 | enum ocelot_ace_action action; |
| 87 | struct ocelot_ace_stats stats; |
| 88 | - int chip_port; |
| 89 | + u16 ingress_port_mask; |
| 90 | |
| 91 | enum ocelot_vcap_bit dmac_mc; |
| 92 | enum ocelot_vcap_bit dmac_bc; |
| 93 | --- a/drivers/net/ethernet/mscc/ocelot_flower.c |
| 94 | +++ b/drivers/net/ethernet/mscc/ocelot_flower.c |
| 95 | @@ -177,8 +177,8 @@ struct ocelot_ace_rule *ocelot_ace_rule_ |
| 96 | if (!rule) |
| 97 | return NULL; |
| 98 | |
| 99 | - rule->port = &block->priv->port; |
| 100 | - rule->chip_port = block->priv->chip_port; |
| 101 | + rule->ocelot = block->priv->port.ocelot; |
| 102 | + rule->ingress_port_mask = BIT(block->priv->chip_port); |
| 103 | return rule; |
| 104 | } |
| 105 | |
| 106 | @@ -213,7 +213,7 @@ static int ocelot_flower_destroy(struct |
| 107 | int ret; |
| 108 | |
| 109 | rule.prio = f->common.prio; |
| 110 | - rule.port = &port_block->priv->port; |
| 111 | + rule.ocelot = port_block->priv->port.ocelot; |
| 112 | rule.id = f->cookie; |
| 113 | |
| 114 | ret = ocelot_ace_rule_offload_del(&rule); |
| 115 | @@ -231,7 +231,7 @@ static int ocelot_flower_stats_update(st |
| 116 | int ret; |
| 117 | |
| 118 | rule.prio = f->common.prio; |
| 119 | - rule.port = &port_block->priv->port; |
| 120 | + rule.ocelot = port_block->priv->port.ocelot; |
| 121 | rule.id = f->cookie; |
| 122 | ret = ocelot_ace_rule_stats_update(&rule); |
| 123 | if (ret) |