diff options
author | 2024-07-05 14:09:35 +0200 | |
---|---|---|
committer | 2024-12-12 14:45:14 +0000 | |
commit | 8fadde6f0154a735dce2624d56b36bf2276b6a7f (patch) | |
tree | 0ea12e83c4d2d546df9142ec0e65f03f5bf3e044 /src/vnet/pg/pg_api.c | |
parent | 504a7d1c93a2f73023d2552a49df0d6d43970830 (diff) |
pg: misc improvements and fixes
1) pg can typically injects packets in ethernet-input, ip4-input or
ip6-input. Make sure offload offsets are correctly set for ip4-input and
ip6-input.
2) add hw-addr support for ethernet mode (only available through cli)
3) refactor pg creation code to improve the readability by using
data structure pg_interface_args_t
4) fix the pg input and output traces to use headers according to
pg interface mode
5) introduce pg interface flags i.e. checksum, gso, gro
Type: improvement
Change-Id: Iffed502e9c6357d7ef8e8a72217867e8297236aa
Signed-off-by: Benoît Ganne <bganne@cisco.com>
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/pg/pg_api.c')
-rw-r--r-- | src/vnet/pg/pg_api.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/vnet/pg/pg_api.c b/src/vnet/pg/pg_api.c index 57fb40cdda4..68953533b07 100644 --- a/src/vnet/pg/pg_api.c +++ b/src/vnet/pg/pg_api.c @@ -33,11 +33,24 @@ vl_api_pg_create_interface_t_handler (vl_api_pg_create_interface_t * mp) { vl_api_pg_create_interface_reply_t *rmp; int rv = 0; + u32 pg_if_id = ~0; pg_main_t *pg = &pg_main; - u32 pg_if_id = - pg_interface_add_or_get (pg, ntohl (mp->interface_id), mp->gso_enabled, - ntohl (mp->gso_size), 0, PG_MODE_ETHERNET); + pg_interface_args_t args = { 0 }; + + args.mode = PG_MODE_ETHERNET; + args.gso_size = 0; + args.hw_addr_set = 0; + args.flags = 0; + args.if_id = ntohl (mp->interface_id); + + if (mp->gso_enabled) + { + args.flags = PG_INTERFACE_FLAG_GSO; + args.gso_size = ntohl (mp->gso_size); + } + + pg_if_id = pg_interface_add_or_get (pg, &args); pg_interface_t *pi = pool_elt_at_index (pg->interfaces, pg_if_id); REPLY_MACRO2(VL_API_PG_CREATE_INTERFACE_REPLY, @@ -51,11 +64,25 @@ vl_api_pg_create_interface_v2_t_handler (vl_api_pg_create_interface_v2_t *mp) { vl_api_pg_create_interface_v2_reply_t *rmp; int rv = 0; + u32 pg_if_id = ~0; pg_main_t *pg = &pg_main; - u32 pg_if_id = - pg_interface_add_or_get (pg, ntohl (mp->interface_id), mp->gso_enabled, - ntohl (mp->gso_size), 0, (u8) mp->mode); + + pg_interface_args_t args = { 0 }; + + args.mode = (pg_interface_mode_t) mp->mode; + args.gso_size = 0; + args.hw_addr_set = 0; + args.flags = 0; + args.if_id = ntohl (mp->interface_id); + + if (mp->gso_enabled) + { + args.flags = PG_INTERFACE_FLAG_GSO; + args.gso_size = ntohl (mp->gso_size); + } + + pg_if_id = pg_interface_add_or_get (pg, &args); pg_interface_t *pi = pool_elt_at_index (pg->interfaces, pg_if_id); REPLY_MACRO2 (VL_API_PG_CREATE_INTERFACE_V2_REPLY, |