summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/af_packet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/devices/af_packet')
-rw-r--r--src/vnet/devices/af_packet/af_packet.api40
-rw-r--r--src/vnet/devices/af_packet/af_packet.c77
-rw-r--r--src/vnet/devices/af_packet/af_packet.h21
-rw-r--r--src/vnet/devices/af_packet/af_packet_api.c65
-rw-r--r--src/vnet/devices/af_packet/cli.c49
-rw-r--r--src/vnet/devices/af_packet/device.c27
-rw-r--r--src/vnet/devices/af_packet/node.c2
7 files changed, 185 insertions, 96 deletions
diff --git a/src/vnet/devices/af_packet/af_packet.api b/src/vnet/devices/af_packet/af_packet.api
index 035096e17a8..c7a81c58f65 100644
--- a/src/vnet/devices/af_packet/af_packet.api
+++ b/src/vnet/devices/af_packet/af_packet.api
@@ -46,6 +46,46 @@ define af_packet_create_reply
vl_api_interface_index_t sw_if_index;
};
+/** \brief Create host-interface
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param hw_addr - interface MAC
+ @param use_random_hw_addr - use random generated MAC
+ @param host_if_name - interface name
+ @param rx_frame_size - frame size for RX
+ @param tx_frame_size - frame size for TX
+ @param rx_frames_per_block - frames per block for RX
+ @param tx_frames_per_block - frames per block for TX
+ @param flags - flags for the af_packet interface creation
+ @param num_rx_queues - number of rx queues
+*/
+define af_packet_create_v2
+{
+ u32 client_index;
+ u32 context;
+
+ vl_api_mac_address_t hw_addr;
+ bool use_random_hw_addr;
+ string host_if_name[64];
+ u32 rx_frame_size;
+ u32 tx_frame_size;
+ u32 rx_frames_per_block;
+ u32 tx_frames_per_block;
+ u32 flags;
+ u16 num_rx_queues [default=1];
+};
+
+/** \brief Create host-interface response
+ @param context - sender context, to match reply w/ request
+ @param retval - return value for request
+*/
+define af_packet_create_v2_reply
+{
+ u32 context;
+ i32 retval;
+ vl_api_interface_index_t sw_if_index;
+};
+
/** \brief Delete host-interface
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index cace3450e3e..2dc263046cb 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -38,21 +38,13 @@
af_packet_main_t af_packet_main;
-#define AF_PACKET_TX_FRAMES_PER_BLOCK 1024
-#define AF_PACKET_TX_FRAME_SIZE (2048 * 5)
+#define AF_PACKET_DEFAULT_TX_FRAMES_PER_BLOCK 1024
+#define AF_PACKET_DEFAULT_TX_FRAME_SIZE (2048 * 5)
#define AF_PACKET_TX_BLOCK_NR 1
-#define AF_PACKET_TX_FRAME_NR (AF_PACKET_TX_BLOCK_NR * \
- AF_PACKET_TX_FRAMES_PER_BLOCK)
-#define AF_PACKET_TX_BLOCK_SIZE (AF_PACKET_TX_FRAME_SIZE * \
- AF_PACKET_TX_FRAMES_PER_BLOCK)
-#define AF_PACKET_RX_FRAMES_PER_BLOCK 1024
-#define AF_PACKET_RX_FRAME_SIZE (2048 * 5)
+#define AF_PACKET_DEFAULT_RX_FRAMES_PER_BLOCK 1024
+#define AF_PACKET_DEFAULT_RX_FRAME_SIZE (2048 * 5)
#define AF_PACKET_RX_BLOCK_NR 1
-#define AF_PACKET_RX_FRAME_NR (AF_PACKET_RX_BLOCK_NR * \
- AF_PACKET_RX_FRAMES_PER_BLOCK)
-#define AF_PACKET_RX_BLOCK_SIZE (AF_PACKET_RX_FRAME_SIZE * \
- AF_PACKET_RX_FRAMES_PER_BLOCK)
/*defined in net/if.h but clashes with dpdk headers */
unsigned int if_nametoindex (const char *ifname);
@@ -241,10 +233,10 @@ error:
}
int
-af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
- u32 * sw_if_index)
+af_packet_create_if (af_packet_create_if_arg_t *arg)
{
af_packet_main_t *apm = &af_packet_main;
+ vlib_main_t *vm = vlib_get_main ();
int ret, fd = -1, fd2 = -1;
struct tpacket_req *rx_req = 0;
struct tpacket_req *tx_req = 0;
@@ -261,28 +253,41 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
uword if_index;
u8 *host_if_name_dup = 0;
int host_if_index = -1;
+ u32 rx_frames_per_block, tx_frames_per_block;
+ u32 rx_frame_size, tx_frame_size;
- p = mhash_get (&apm->if_index_by_host_if_name, host_if_name);
+ p = mhash_get (&apm->if_index_by_host_if_name, arg->host_if_name);
if (p)
{
apif = vec_elt_at_index (apm->interfaces, p[0]);
- *sw_if_index = apif->sw_if_index;
+ arg->sw_if_index = apif->sw_if_index;
return VNET_API_ERROR_IF_ALREADY_EXISTS;
}
- host_if_name_dup = vec_dup (host_if_name);
+ host_if_name_dup = vec_dup (arg->host_if_name);
+
+ rx_frames_per_block = arg->rx_frames_per_block ?
+ arg->rx_frames_per_block :
+ AF_PACKET_DEFAULT_RX_FRAMES_PER_BLOCK;
+ tx_frames_per_block = arg->tx_frames_per_block ?
+ arg->tx_frames_per_block :
+ AF_PACKET_DEFAULT_TX_FRAMES_PER_BLOCK;
+ rx_frame_size =
+ arg->rx_frame_size ? arg->rx_frame_size : AF_PACKET_DEFAULT_RX_FRAME_SIZE;
+ tx_frame_size =
+ arg->tx_frame_size ? arg->tx_frame_size : AF_PACKET_DEFAULT_TX_FRAME_SIZE;
vec_validate (rx_req, 0);
- rx_req->tp_block_size = AF_PACKET_RX_BLOCK_SIZE;
- rx_req->tp_frame_size = AF_PACKET_RX_FRAME_SIZE;
+ rx_req->tp_block_size = rx_frame_size * rx_frames_per_block;
+ rx_req->tp_frame_size = rx_frame_size;
rx_req->tp_block_nr = AF_PACKET_RX_BLOCK_NR;
- rx_req->tp_frame_nr = AF_PACKET_RX_FRAME_NR;
+ rx_req->tp_frame_nr = AF_PACKET_RX_BLOCK_NR * rx_frames_per_block;
vec_validate (tx_req, 0);
- tx_req->tp_block_size = AF_PACKET_TX_BLOCK_SIZE;
- tx_req->tp_frame_size = AF_PACKET_TX_FRAME_SIZE;
+ tx_req->tp_block_size = tx_frame_size * tx_frames_per_block;
+ tx_req->tp_frame_size = tx_frame_size;
tx_req->tp_block_nr = AF_PACKET_TX_BLOCK_NR;
- tx_req->tp_frame_nr = AF_PACKET_TX_FRAME_NR;
+ tx_req->tp_frame_nr = AF_PACKET_TX_BLOCK_NR * tx_frames_per_block;
/*
* make sure host side of interface is 'UP' before binding AF_PACKET
@@ -297,13 +302,14 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
goto error;
}
- clib_memcpy (ifr.ifr_name, (const char *) host_if_name,
- vec_len (host_if_name));
+ clib_memcpy (ifr.ifr_name, (const char *) arg->host_if_name,
+ vec_len (arg->host_if_name));
if (ioctl (fd2, SIOCGIFINDEX, &ifr) < 0)
{
- vlib_log_debug (apm->log_class,
- "Failed to retrieve the interface (%s) index: %s (errno %d)",
- host_if_name, strerror (errno), errno);
+ vlib_log_debug (
+ apm->log_class,
+ "Failed to retrieve the interface (%s) index: %s (errno %d)",
+ arg->host_if_name, strerror (errno), errno);
ret = VNET_API_ERROR_INVALID_INTERFACE;
goto error;
}
@@ -342,7 +348,7 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
if (ret != 0)
goto error;
- ret = is_bridge (host_if_name);
+ ret = is_bridge (arg->host_if_name);
if (ret == 0) /* is a bridge, ignore state */
host_if_index = -1;
@@ -370,8 +376,8 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
clib_spinlock_init (&apif->lockp);
/*use configured or generate random MAC address */
- if (hw_addr_set)
- clib_memcpy (hw_addr, hw_addr_set, 6);
+ if (arg->hw_addr)
+ clib_memcpy (hw_addr, arg->hw_addr, 6);
else
{
f64 now = vlib_time_now (vm);
@@ -429,8 +435,7 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
mhash_set_mem (&apm->if_index_by_host_if_name, host_if_name_dup, &if_index,
0);
- if (sw_if_index)
- *sw_if_index = apif->sw_if_index;
+ arg->sw_if_index = apif->sw_if_index;
return 0;
@@ -447,7 +452,7 @@ error:
}
int
-af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name)
+af_packet_delete_if (u8 *host_if_name)
{
vnet_main_t *vnm = vnet_get_main ();
af_packet_main_t *apm = &af_packet_main;
@@ -507,7 +512,7 @@ af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name)
}
int
-af_packet_set_l4_cksum_offload (vlib_main_t * vm, u32 sw_if_index, u8 set)
+af_packet_set_l4_cksum_offload (u32 sw_if_index, u8 set)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hw;
@@ -538,7 +543,6 @@ af_packet_dump_ifs (af_packet_if_detail_t ** out_af_packet_ifs)
af_packet_if_detail_t *r_af_packet_ifs = NULL;
af_packet_if_detail_t *af_packet_if = NULL;
- /* *INDENT-OFF* */
pool_foreach (apif, apm->interfaces)
{
vec_add2 (r_af_packet_ifs, af_packet_if, 1);
@@ -550,7 +554,6 @@ af_packet_dump_ifs (af_packet_if_detail_t ** out_af_packet_ifs)
strlen ((const char *) apif->host_if_name)));
}
}
- /* *INDENT-ON* */
*out_af_packet_ifs = r_af_packet_ifs;
diff --git a/src/vnet/devices/af_packet/af_packet.h b/src/vnet/devices/af_packet/af_packet.h
index fc35b48b85e..3163aa0323e 100644
--- a/src/vnet/devices/af_packet/af_packet.h
+++ b/src/vnet/devices/af_packet/af_packet.h
@@ -69,15 +69,26 @@ typedef struct
vlib_log_class_t log_class;
} af_packet_main_t;
+typedef struct
+{
+ u8 *host_if_name;
+ u8 *hw_addr;
+ u32 rx_frame_size;
+ u32 tx_frame_size;
+ u32 rx_frames_per_block;
+ u32 tx_frames_per_block;
+
+ /* return */
+ u32 sw_if_index;
+} af_packet_create_if_arg_t;
+
extern af_packet_main_t af_packet_main;
extern vnet_device_class_t af_packet_device_class;
extern vlib_node_registration_t af_packet_input_node;
-int af_packet_create_if (vlib_main_t * vm, u8 * host_if_name,
- u8 * hw_addr_set, u32 * sw_if_index);
-int af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name);
-int af_packet_set_l4_cksum_offload (vlib_main_t * vm, u32 sw_if_index,
- u8 set);
+int af_packet_create_if (af_packet_create_if_arg_t *arg);
+int af_packet_delete_if (u8 *host_if_name);
+int af_packet_set_l4_cksum_offload (u32 sw_if_index, u8 set);
int af_packet_dump_ifs (af_packet_if_detail_t ** out_af_packet_ifs);
format_function_t format_af_packet_device_name;
diff --git a/src/vnet/devices/af_packet/af_packet_api.c b/src/vnet/devices/af_packet/af_packet_api.c
index d4d041ffb3c..80a2d9222c6 100644
--- a/src/vnet/devices/af_packet/af_packet_api.c
+++ b/src/vnet/devices/af_packet/af_packet_api.c
@@ -36,33 +36,61 @@ static u16 msg_id_base;
static void
vl_api_af_packet_create_t_handler (vl_api_af_packet_create_t * mp)
{
- vlib_main_t *vm = vlib_get_main ();
+ af_packet_create_if_arg_t _arg, *arg = &_arg;
vl_api_af_packet_create_reply_t *rmp;
int rv = 0;
- u8 *host_if_name = NULL;
- u32 sw_if_index;
- host_if_name = format (0, "%s", mp->host_if_name);
- vec_add1 (host_if_name, 0);
+ clib_memset (arg, 0, sizeof (*arg));
- rv = af_packet_create_if (vm, host_if_name,
- mp->use_random_hw_addr ? 0 : mp->hw_addr,
- &sw_if_index);
+ arg->host_if_name = format (0, "%s", mp->host_if_name);
+ vec_add1 (arg->host_if_name, 0);
- vec_free (host_if_name);
+ arg->hw_addr = mp->use_random_hw_addr ? 0 : mp->hw_addr;
+ rv = af_packet_create_if (arg);
+
+ vec_free (arg->host_if_name);
+
+ REPLY_MACRO2 (VL_API_AF_PACKET_CREATE_REPLY, ({
+ rmp->sw_if_index = clib_host_to_net_u32 (arg->sw_if_index);
+ }));
+}
+
+static void
+vl_api_af_packet_create_v2_t_handler (vl_api_af_packet_create_v2_t *mp)
+{
+ af_packet_create_if_arg_t _arg, *arg = &_arg;
+ vl_api_af_packet_create_v2_reply_t *rmp;
+ int rv = 0;
+
+ clib_memset (arg, 0, sizeof (*arg));
+
+ arg->host_if_name = format (0, "%s", mp->host_if_name);
+ vec_add1 (arg->host_if_name, 0);
+
+ arg->rx_frame_size = clib_net_to_host_u32 (mp->rx_frame_size);
+ arg->tx_frame_size = clib_net_to_host_u32 (mp->tx_frame_size);
+ arg->rx_frames_per_block = clib_net_to_host_u32 (mp->rx_frames_per_block);
+ arg->tx_frames_per_block = clib_net_to_host_u32 (mp->tx_frames_per_block);
+ arg->hw_addr = mp->use_random_hw_addr ? 0 : mp->hw_addr;
+
+ if (mp->num_rx_queues > 1)
+ {
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto out;
+ }
+
+ rv = af_packet_create_if (arg);
- /* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_AF_PACKET_CREATE_REPLY,
- ({
- rmp->sw_if_index = clib_host_to_net_u32(sw_if_index);
- }));
- /* *INDENT-ON* */
+out:
+ vec_free (arg->host_if_name);
+ REPLY_MACRO2 (VL_API_AF_PACKET_CREATE_V2_REPLY, ({
+ rmp->sw_if_index = clib_host_to_net_u32 (arg->sw_if_index);
+ }));
}
static void
vl_api_af_packet_delete_t_handler (vl_api_af_packet_delete_t * mp)
{
- vlib_main_t *vm = vlib_get_main ();
vl_api_af_packet_delete_reply_t *rmp;
int rv = 0;
u8 *host_if_name = NULL;
@@ -70,7 +98,7 @@ vl_api_af_packet_delete_t_handler (vl_api_af_packet_delete_t * mp)
host_if_name = format (0, "%s", mp->host_if_name);
vec_add1 (host_if_name, 0);
- rv = af_packet_delete_if (vm, host_if_name);
+ rv = af_packet_delete_if (host_if_name);
vec_free (host_if_name);
@@ -81,11 +109,10 @@ static void
vl_api_af_packet_set_l4_cksum_offload_t_handler
(vl_api_af_packet_set_l4_cksum_offload_t * mp)
{
- vlib_main_t *vm = vlib_get_main ();
vl_api_af_packet_delete_reply_t *rmp;
int rv = 0;
- rv = af_packet_set_l4_cksum_offload (vm, ntohl (mp->sw_if_index), mp->set);
+ rv = af_packet_set_l4_cksum_offload (ntohl (mp->sw_if_index), mp->set);
REPLY_MACRO (VL_API_AF_PACKET_SET_L4_CKSUM_OFFLOAD_REPLY);
}
diff --git a/src/vnet/devices/af_packet/cli.c b/src/vnet/devices/af_packet/cli.c
index e5466c9599d..bae4f6181b0 100644
--- a/src/vnet/devices/af_packet/cli.c
+++ b/src/vnet/devices/af_packet/cli.c
@@ -44,12 +44,12 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
- u8 *host_if_name = NULL;
+ af_packet_create_if_arg_t _arg, *arg = &_arg;
+ clib_error_t *error = NULL;
u8 hwaddr[6];
- u8 *hw_addr_ptr = 0;
- u32 sw_if_index;
int r;
- clib_error_t *error = NULL;
+
+ clib_memset (arg, 0, sizeof (*arg));
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
@@ -57,12 +57,21 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "name %s", &host_if_name))
+ if (unformat (line_input, "name %s", &arg->host_if_name))
;
- else
- if (unformat
- (line_input, "hw-addr %U", unformat_ethernet_address, hwaddr))
- hw_addr_ptr = hwaddr;
+ else if (unformat (line_input, "rx-size %u", &arg->rx_frame_size))
+ ;
+ else if (unformat (line_input, "tx-size %u", &arg->tx_frame_size))
+ ;
+ else if (unformat (line_input, "rx-per-block %u",
+ &arg->rx_frames_per_block))
+ ;
+ else if (unformat (line_input, "tx-per-block %u",
+ &arg->tx_frames_per_block))
+ ;
+ else if (unformat (line_input, "hw-addr %U", unformat_ethernet_address,
+ hwaddr))
+ arg->hw_addr = hwaddr;
else
{
error = clib_error_return (0, "unknown input `%U'",
@@ -71,13 +80,13 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
}
}
- if (host_if_name == NULL)
+ if (arg->host_if_name == NULL)
{
error = clib_error_return (0, "missing host interface name");
goto done;
}
- r = af_packet_create_if (vm, host_if_name, hw_addr_ptr, &sw_if_index);
+ r = af_packet_create_if (arg);
if (r == VNET_API_ERROR_SYSCALL_ERROR_1)
{
@@ -98,10 +107,10 @@ af_packet_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
}
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
- sw_if_index);
+ arg->sw_if_index);
done:
- vec_free (host_if_name);
+ vec_free (arg->host_if_name);
unformat_free (line_input);
return error;
@@ -129,13 +138,11 @@ done:
* Once the host interface is created, enable the interface using:
* @cliexcmd{set interface state host-vpp1 up}
?*/
-/* *INDENT-OFF* */
VLIB_CLI_COMMAND (af_packet_create_command, static) = {
.path = "create host-interface",
.short_help = "create host-interface name <ifname> [hw-addr <mac-addr>]",
.function = af_packet_create_command_fn,
};
-/* *INDENT-ON* */
static clib_error_t *
af_packet_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
@@ -167,7 +174,7 @@ af_packet_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
goto done;
}
- af_packet_delete_if (vm, host_if_name);
+ af_packet_delete_if (host_if_name);
done:
vec_free (host_if_name);
@@ -186,13 +193,11 @@ done:
* Example of how to delete a host interface named host-vpp1:
* @cliexcmd{delete host-interface name vpp1}
?*/
-/* *INDENT-OFF* */
VLIB_CLI_COMMAND (af_packet_delete_command, static) = {
.path = "delete host-interface",
.short_help = "delete host-interface name <ifname>",
.function = af_packet_delete_command_fn,
};
-/* *INDENT-ON* */
static clib_error_t *
af_packet_set_l4_cksum_offload_command_fn (vlib_main_t * vm,
@@ -210,8 +215,8 @@ af_packet_set_l4_cksum_offload_command_fn (vlib_main_t * vm,
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat
- (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
+ if (unformat (line_input, "%U", unformat_vnet_sw_interface, vnm,
+ &sw_if_index))
;
else if (unformat (line_input, "on"))
set = 1;
@@ -225,7 +230,7 @@ af_packet_set_l4_cksum_offload_command_fn (vlib_main_t * vm,
}
}
- if (af_packet_set_l4_cksum_offload (vm, sw_if_index, set) < 0)
+ if (af_packet_set_l4_cksum_offload (sw_if_index, set) < 0)
error = clib_error_return (0, "not an af_packet interface");
done:
@@ -243,13 +248,11 @@ done:
* @cliexcmd{set host-interface l4-cksum-offload host-vpp0 off}
* @cliexcmd{set host-interface l4-cksum-offload host-vpp0 on}
?*/
-/* *INDENT-OFF* */
VLIB_CLI_COMMAND (af_packet_set_l4_cksum_offload_command, static) = {
.path = "set host-interface l4-cksum-offload",
.short_help = "set host-interface l4-cksum-offload <host-if-name> <on|off>",
.function = af_packet_set_l4_cksum_offload_command_fn,
};
-/* *INDENT-ON* */
clib_error_t *
af_packet_cli_init (vlib_main_t * vm)
diff --git a/src/vnet/devices/af_packet/device.c b/src/vnet/devices/af_packet/device.c
index 8a6ff1de649..0542b165a3a 100644
--- a/src/vnet/devices/af_packet/device.c
+++ b/src/vnet/devices/af_packet/device.c
@@ -74,25 +74,34 @@ format_af_packet_device (u8 * s, va_list * args)
af_packet_main_t *apm = &af_packet_main;
af_packet_if_t *apif = pool_elt_at_index (apm->interfaces, dev_instance);
clib_spinlock_lock_if_init (&apif->lockp);
- u32 block_size = apif->tx_req->tp_block_size;
- u32 frame_size = apif->tx_req->tp_frame_size;
- u32 frame_num = apif->tx_req->tp_frame_nr;
+ u32 tx_block_sz = apif->tx_req->tp_block_size;
+ u32 tx_frame_sz = apif->tx_req->tp_frame_size;
+ u32 tx_frame_nr = apif->tx_req->tp_frame_nr;
+ u32 tx_block_nr = apif->tx_req->tp_block_nr;
+ u32 rx_block_size = apif->rx_req->tp_block_size;
+ u32 rx_frame_size = apif->rx_req->tp_frame_size;
+ u32 rx_frame_nr = apif->rx_req->tp_frame_nr;
+ u32 rx_block_nr = apif->rx_req->tp_block_nr;
int block = 0;
- u8 *block_start = apif->tx_ring + block * block_size;
+ u8 *tx_block_start = apif->tx_ring + block * tx_block_sz;
u32 tx_frame = apif->next_tx_frame;
struct tpacket2_hdr *tph;
s = format (s, "Linux PACKET socket interface\n");
- s = format (s, "%Ublock:%d frame:%d\n", format_white_space, indent,
- block_size, frame_size);
+ s = format (s, "%UTX block size:%d nr:%d TX frame size:%d nr:%d\n",
+ format_white_space, indent, tx_block_sz, tx_block_nr,
+ tx_frame_sz, tx_frame_nr);
+ s = format (s, "%URX block size:%d nr:%d RX frame size:%d nr:%d\n",
+ format_white_space, indent, rx_block_size, rx_block_nr,
+ rx_frame_size, rx_frame_nr);
s = format (s, "%Unext frame:%d\n", format_white_space, indent,
apif->next_tx_frame);
int n_send_req = 0, n_avail = 0, n_sending = 0, n_tot = 0, n_wrong = 0;
do
{
- tph = (struct tpacket2_hdr *) (block_start + tx_frame * frame_size);
- tx_frame = (tx_frame + 1) % frame_num;
+ tph = (struct tpacket2_hdr *) (tx_block_start + tx_frame * tx_frame_sz);
+ tx_frame = (tx_frame + 1) % tx_frame_nr;
if (tph->tp_status == 0)
n_avail++;
else if (tph->tp_status & TP_STATUS_SEND_REQUEST)
@@ -371,7 +380,6 @@ error:
return 0; /* no error */
}
-/* *INDENT-OFF* */
VNET_DEVICE_CLASS (af_packet_device_class) = {
.name = "af-packet",
.format_device_name = format_af_packet_device_name,
@@ -385,7 +393,6 @@ VNET_DEVICE_CLASS (af_packet_device_class) = {
.subif_add_del_function = af_packet_subif_add_del_function,
.mac_addr_change_function = af_packet_set_mac_address_function,
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vnet/devices/af_packet/node.c b/src/vnet/devices/af_packet/node.c
index 9fd115f9509..caddcfa416b 100644
--- a/src/vnet/devices/af_packet/node.c
+++ b/src/vnet/devices/af_packet/node.c
@@ -387,7 +387,6 @@ VLIB_NODE_FN (af_packet_input_node) (vlib_main_t * vm,
return n_rx_packets;
}
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE (af_packet_input_node) = {
.name = "af-packet-input",
.flags = VLIB_NODE_FLAG_TRACE_SUPPORTED,
@@ -398,7 +397,6 @@ VLIB_REGISTER_NODE (af_packet_input_node) = {
.n_errors = AF_PACKET_INPUT_N_ERROR,
.error_strings = af_packet_input_error_strings,
};
-/* *INDENT-ON* */
/*