summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/rocker/rocker_ofdpa.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/rocker/rocker_ofdpa.c')
-rw-r--r--drivers/net/ethernet/rocker/rocker_ofdpa.c63
1 files changed, 23 insertions, 40 deletions
diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c
index 826990459fa4..66a8ae67c3ea 100644
--- a/drivers/net/ethernet/rocker/rocker_ofdpa.c
+++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c
@@ -104,7 +104,6 @@ struct ofdpa_group_tbl_entry {
u32 cmd;
u32 group_id; /* key */
u16 group_count;
- u32 *group_ids;
union {
struct {
u8 pop_vlan;
@@ -123,6 +122,8 @@ struct ofdpa_group_tbl_entry {
u32 group_id;
} l3_unicast;
};
+
+ u32 group_ids[] __counted_by(group_count);
};
struct ofdpa_fdb_tbl_entry {
@@ -838,7 +839,7 @@ static int ofdpa_flow_tbl_ig_port(struct ofdpa_port *ofdpa_port, int flags,
{
struct ofdpa_flow_tbl_entry *entry;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
@@ -860,7 +861,7 @@ static int ofdpa_flow_tbl_vlan(struct ofdpa_port *ofdpa_port,
{
struct ofdpa_flow_tbl_entry *entry;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
@@ -886,7 +887,7 @@ static int ofdpa_flow_tbl_term_mac(struct ofdpa_port *ofdpa_port,
{
struct ofdpa_flow_tbl_entry *entry;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
@@ -926,7 +927,7 @@ static int ofdpa_flow_tbl_bridge(struct ofdpa_port *ofdpa_port,
bool dflt = !eth_dst || eth_dst_mask;
bool wild = false;
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (!entry)
return -ENOMEM;
@@ -976,7 +977,7 @@ static int ofdpa_flow_tbl_ucast4_routing(struct ofdpa_port *ofdpa_port,
{
struct ofdpa_flow_tbl_entry *entry;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
@@ -1006,7 +1007,7 @@ static int ofdpa_flow_tbl_acl(struct ofdpa_port *ofdpa_port, int flags,
u32 priority;
struct ofdpa_flow_tbl_entry *entry;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
@@ -1059,19 +1060,6 @@ ofdpa_group_tbl_find(const struct ofdpa *ofdpa,
return NULL;
}
-static void ofdpa_group_tbl_entry_free(struct ofdpa_group_tbl_entry *entry)
-{
- switch (ROCKER_GROUP_TYPE_GET(entry->group_id)) {
- case ROCKER_OF_DPA_GROUP_TYPE_L2_FLOOD:
- case ROCKER_OF_DPA_GROUP_TYPE_L2_MCAST:
- kfree(entry->group_ids);
- break;
- default:
- break;
- }
- kfree(entry);
-}
-
static int ofdpa_group_tbl_add(struct ofdpa_port *ofdpa_port, int flags,
struct ofdpa_group_tbl_entry *match)
{
@@ -1085,7 +1073,7 @@ static int ofdpa_group_tbl_add(struct ofdpa_port *ofdpa_port, int flags,
if (found) {
hash_del(&found->entry);
- ofdpa_group_tbl_entry_free(found);
+ kfree(found);
found = match;
found->cmd = ROCKER_TLV_CMD_TYPE_OF_DPA_GROUP_MOD;
} else {
@@ -1122,14 +1110,14 @@ static int ofdpa_group_tbl_del(struct ofdpa_port *ofdpa_port, int flags,
spin_unlock_irqrestore(&ofdpa->group_tbl_lock, lock_flags);
- ofdpa_group_tbl_entry_free(match);
+ kfree(match);
if (found) {
err = rocker_cmd_exec(ofdpa_port->rocker_port,
ofdpa_flags_nowait(flags),
ofdpa_cmd_group_tbl_del,
found, NULL, NULL);
- ofdpa_group_tbl_entry_free(found);
+ kfree(found);
}
return err;
@@ -1150,7 +1138,7 @@ static int ofdpa_group_l2_interface(struct ofdpa_port *ofdpa_port,
{
struct ofdpa_group_tbl_entry *entry;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
@@ -1166,18 +1154,13 @@ static int ofdpa_group_l2_fan_out(struct ofdpa_port *ofdpa_port,
{
struct ofdpa_group_tbl_entry *entry;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_flex(*entry, group_ids, group_count);
if (!entry)
return -ENOMEM;
- entry->group_id = group_id;
entry->group_count = group_count;
+ entry->group_id = group_id;
- entry->group_ids = kcalloc(group_count, sizeof(u32), GFP_KERNEL);
- if (!entry->group_ids) {
- kfree(entry);
- return -ENOMEM;
- }
memcpy(entry->group_ids, group_ids, group_count * sizeof(u32));
return ofdpa_group_tbl_do(ofdpa_port, flags, entry);
@@ -1199,7 +1182,7 @@ static int ofdpa_group_l3_unicast(struct ofdpa_port *ofdpa_port, int flags,
{
struct ofdpa_group_tbl_entry *entry;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
@@ -1273,7 +1256,7 @@ static int ofdpa_port_ipv4_neigh(struct ofdpa_port *ofdpa_port,
bool removing;
int err = 0;
- entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ entry = kzalloc_obj(*entry, GFP_ATOMIC);
if (!entry)
return -ENOMEM;
@@ -1386,7 +1369,7 @@ static int ofdpa_port_ipv4_nh(struct ofdpa_port *ofdpa_port,
bool resolved = true;
int err = 0;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
@@ -1866,7 +1849,7 @@ static int ofdpa_port_fdb_learn(struct ofdpa_port *ofdpa_port,
if (!(flags & OFDPA_OP_FLAG_LEARNED))
return 0;
- lw = kzalloc(sizeof(*lw), GFP_ATOMIC);
+ lw = kzalloc_obj(*lw, GFP_ATOMIC);
if (!lw)
return -ENOMEM;
@@ -1904,7 +1887,7 @@ static int ofdpa_port_fdb(struct ofdpa_port *ofdpa_port,
bool removing = (flags & OFDPA_OP_FLAG_REMOVE);
unsigned long lock_flags;
- fdb = kzalloc(sizeof(*fdb), GFP_KERNEL);
+ fdb = kzalloc_obj(*fdb);
if (!fdb)
return -ENOMEM;
@@ -1933,7 +1916,7 @@ static int ofdpa_port_fdb(struct ofdpa_port *ofdpa_port,
spin_unlock_irqrestore(&ofdpa->fdb_tbl_lock, lock_flags);
/* Check if adding and already exists, or removing and can't find */
- if (!found != !removing) {
+ if (!found == removing) {
kfree(fdb);
if (!found && removing)
return 0;
@@ -1982,7 +1965,7 @@ err_out:
static void ofdpa_fdb_cleanup(struct timer_list *t)
{
- struct ofdpa *ofdpa = from_timer(ofdpa, t, fdb_cleanup_timer);
+ struct ofdpa *ofdpa = timer_container_of(ofdpa, t, fdb_cleanup_timer);
struct ofdpa_port *ofdpa_port;
struct ofdpa_fdb_tbl_entry *entry;
struct hlist_node *tmp;
@@ -2232,7 +2215,7 @@ static __be16 ofdpa_port_internal_vlan_id_get(struct ofdpa_port *ofdpa_port,
unsigned long lock_flags;
int i;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry);
if (!entry)
return 0;
@@ -2386,7 +2369,7 @@ static void ofdpa_fini(struct rocker *rocker)
struct hlist_node *tmp;
int bkt;
- del_timer_sync(&ofdpa->fdb_cleanup_timer);
+ timer_delete_sync(&ofdpa->fdb_cleanup_timer);
flush_workqueue(rocker->rocker_owq);
spin_lock_irqsave(&ofdpa->flow_tbl_lock, flags);