Commit 23202e09 authored by David S. Miller's avatar David S. Miller

Merge branch 'nfp-dead-code-clean-ups-and-slight-improvements'

Jakub Kicinski says:

====================
nfp: dead code, clean ups and slight improvements

This series contains small clean ups from John and Carl, and brings
no functional changes.

John's improvements target the flower code.  First he makes sure we don't
allocate space in FW request messages for MAC matches if the TC rule does
not contain any.  The remaining two patches remove some dead code and
unused defines.

Carl follows up with a slight optimization to his recent ethtool FW state
dumps, byte swapping input parameters once instead of the data for every
dumped item.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 24fd3190 92a54f4a
......@@ -50,9 +50,6 @@
#define NFP_FLOWER_LAYER_CT BIT(6)
#define NFP_FLOWER_LAYER_VXLAN BIT(7)
#define NFP_FLOWER_LAYER_ETHER BIT(3)
#define NFP_FLOWER_LAYER_ARP BIT(4)
#define NFP_FLOWER_MASK_VLAN_PRIO GENMASK(15, 13)
#define NFP_FLOWER_MASK_VLAN_CFI BIT(12)
#define NFP_FLOWER_MASK_VLAN_VID GENMASK(11, 0)
......@@ -165,20 +162,6 @@ struct nfp_fl_pop_vlan {
__be16 reserved;
};
/* Metadata without L2 (1W/4B)
* ----------------------------------------------------------------
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | key_layers | mask_id | reserved |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct nfp_flower_meta_one {
u8 nfp_flow_key_layer;
u8 mask_id;
u16 reserved;
};
struct nfp_fl_pre_tunnel {
struct nfp_fl_act_head head;
__be16 reserved;
......@@ -209,7 +192,7 @@ struct nfp_fl_set_vxlan {
* NOTE: | TCI |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct nfp_flower_meta_two {
struct nfp_flower_meta_tci {
u8 nfp_flow_key_layer;
u8 mask_id;
__be16 tci;
......
......@@ -38,7 +38,7 @@
#include "main.h"
static void
nfp_flower_compile_meta_tci(struct nfp_flower_meta_two *frame,
nfp_flower_compile_meta_tci(struct nfp_flower_meta_tci *frame,
struct tc_cls_flower_offload *flow, u8 key_type,
bool mask_version)
{
......@@ -46,7 +46,7 @@ nfp_flower_compile_meta_tci(struct nfp_flower_meta_two *frame,
struct flow_dissector_key_vlan *flow_vlan;
u16 tmp_tci;
memset(frame, 0, sizeof(struct nfp_flower_meta_two));
memset(frame, 0, sizeof(struct nfp_flower_meta_tci));
/* Populate the metadata frame. */
frame->nfp_flow_key_layer = key_type;
frame->mask_id = ~0;
......@@ -67,14 +67,6 @@ nfp_flower_compile_meta_tci(struct nfp_flower_meta_two *frame,
}
}
static void
nfp_flower_compile_meta(struct nfp_flower_meta_one *frame, u8 key_type)
{
frame->nfp_flow_key_layer = key_type;
frame->mask_id = 0;
frame->reserved = 0;
}
static int
nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port,
bool mask_version, enum nfp_flower_tun_type tun_type)
......@@ -278,49 +270,32 @@ int nfp_flower_compile_flow_match(struct tc_cls_flower_offload *flow,
ext = nfp_flow->unmasked_data;
msk = nfp_flow->mask_data;
if (NFP_FLOWER_LAYER_PORT & key_ls->key_layer) {
/* Populate Exact Metadata. */
nfp_flower_compile_meta_tci((struct nfp_flower_meta_two *)ext,
flow, key_ls->key_layer, false);
/* Populate Mask Metadata. */
nfp_flower_compile_meta_tci((struct nfp_flower_meta_two *)msk,
flow, key_ls->key_layer, true);
ext += sizeof(struct nfp_flower_meta_two);
msk += sizeof(struct nfp_flower_meta_two);
/* Populate Exact Port data. */
err = nfp_flower_compile_port((struct nfp_flower_in_port *)ext,
nfp_repr_get_port_id(netdev),
false, tun_type);
if (err)
return err;
/* Populate Mask Port Data. */
err = nfp_flower_compile_port((struct nfp_flower_in_port *)msk,
nfp_repr_get_port_id(netdev),
true, tun_type);
if (err)
return err;
ext += sizeof(struct nfp_flower_in_port);
msk += sizeof(struct nfp_flower_in_port);
} else {
/* Populate Exact Metadata. */
nfp_flower_compile_meta((struct nfp_flower_meta_one *)ext,
key_ls->key_layer);
/* Populate Mask Metadata. */
nfp_flower_compile_meta((struct nfp_flower_meta_one *)msk,
key_ls->key_layer);
ext += sizeof(struct nfp_flower_meta_one);
msk += sizeof(struct nfp_flower_meta_one);
}
if (NFP_FLOWER_LAYER_META & key_ls->key_layer) {
/* Additional Metadata Fields.
* Currently unsupported.
*/
return -EOPNOTSUPP;
}
/* Populate Exact Metadata. */
nfp_flower_compile_meta_tci((struct nfp_flower_meta_tci *)ext,
flow, key_ls->key_layer, false);
/* Populate Mask Metadata. */
nfp_flower_compile_meta_tci((struct nfp_flower_meta_tci *)msk,
flow, key_ls->key_layer, true);
ext += sizeof(struct nfp_flower_meta_tci);
msk += sizeof(struct nfp_flower_meta_tci);
/* Populate Exact Port data. */
err = nfp_flower_compile_port((struct nfp_flower_in_port *)ext,
nfp_repr_get_port_id(netdev),
false, tun_type);
if (err)
return err;
/* Populate Mask Port Data. */
err = nfp_flower_compile_port((struct nfp_flower_in_port *)msk,
nfp_repr_get_port_id(netdev),
true, tun_type);
if (err)
return err;
ext += sizeof(struct nfp_flower_in_port);
msk += sizeof(struct nfp_flower_in_port);
if (NFP_FLOWER_LAYER_MAC & key_ls->key_layer) {
/* Populate Exact MAC Data. */
......
......@@ -150,10 +150,15 @@ nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
return -EOPNOTSUPP;
key_layer_two = 0;
key_layer = NFP_FLOWER_LAYER_PORT | NFP_FLOWER_LAYER_MAC;
key_size = sizeof(struct nfp_flower_meta_one) +
sizeof(struct nfp_flower_in_port) +
sizeof(struct nfp_flower_mac_mpls);
key_layer = NFP_FLOWER_LAYER_PORT;
key_size = sizeof(struct nfp_flower_meta_tci) +
sizeof(struct nfp_flower_in_port);
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_ETH_ADDRS) ||
dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_MPLS)) {
key_layer |= NFP_FLOWER_LAYER_MAC;
key_size += sizeof(struct nfp_flower_mac_mpls);
}
if (dissector_uses_key(flow->dissector,
FLOW_DISSECTOR_KEY_ENC_CONTROL)) {
......
......@@ -126,13 +126,13 @@ struct nfp_dump_error {
/* to track state through debug size calculation TLV traversal */
struct nfp_level_size {
u32 requested_level; /* input */
__be32 requested_level; /* input */
u32 total_size; /* output */
};
/* to track state during debug dump creation TLV traversal */
struct nfp_dump_state {
u32 requested_level; /* input param */
__be32 requested_level; /* input param */
u32 dumped_size; /* adds up to size of dumped data */
u32 buf_size; /* size of buffer pointer to by p */
void *p; /* current point in dump buffer */
......@@ -334,7 +334,7 @@ nfp_calc_specific_level_size(struct nfp_pf *pf, struct nfp_dump_tl *dump_level,
{
struct nfp_level_size *lev_sz = param;
if (be32_to_cpu(dump_level->type) != lev_sz->requested_level)
if (dump_level->type != lev_sz->requested_level)
return 0;
return nfp_traverse_tlvs(pf, dump_level->data,
......@@ -348,7 +348,7 @@ s64 nfp_net_dump_calculate_size(struct nfp_pf *pf, struct nfp_dumpspec *spec,
struct nfp_level_size lev_sz;
int err;
lev_sz.requested_level = flag;
lev_sz.requested_level = cpu_to_be32(flag);
lev_sz.total_size = ALIGN8(sizeof(struct nfp_dump_prolog));
err = nfp_traverse_tlvs(pf, spec->data, spec->size, &lev_sz,
......@@ -733,7 +733,7 @@ nfp_dump_specific_level(struct nfp_pf *pf, struct nfp_dump_tl *dump_level,
{
struct nfp_dump_state *dump = param;
if (be32_to_cpu(dump_level->type) != dump->requested_level)
if (dump_level->type != dump->requested_level)
return 0;
return nfp_traverse_tlvs(pf, dump_level->data,
......@@ -753,7 +753,7 @@ static int nfp_dump_populate_prolog(struct nfp_dump_state *dump)
if (err)
return err;
prolog->dump_level = cpu_to_be32(dump->requested_level);
prolog->dump_level = dump->requested_level;
return 0;
}
......@@ -764,7 +764,7 @@ int nfp_net_dump_populate_buffer(struct nfp_pf *pf, struct nfp_dumpspec *spec,
struct nfp_dump_state dump;
int err;
dump.requested_level = dump_param->flag;
dump.requested_level = cpu_to_be32(dump_param->flag);
dump.dumped_size = 0;
dump.p = dest;
dump.buf_size = dump_param->len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment