diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/acl/hash_lookup.c | 22 | ||||
-rw-r--r-- | src/plugins/dev_octeon/crypto.c | 4 | ||||
-rw-r--r-- | src/plugins/dev_octeon/crypto.h | 7 | ||||
-rw-r--r-- | src/plugins/dev_octeon/init.c | 43 | ||||
-rw-r--r-- | src/plugins/dev_octeon/octeon.h | 6 | ||||
-rw-r--r-- | src/vat2/main.c | 35 |
6 files changed, 75 insertions, 42 deletions
diff --git a/src/plugins/acl/hash_lookup.c b/src/plugins/acl/hash_lookup.c index 9c3c662a8f1..b4f86208a71 100644 --- a/src/plugins/acl/hash_lookup.c +++ b/src/plugins/acl/hash_lookup.c @@ -946,31 +946,15 @@ hash_acl_reapply(acl_main_t *am, u32 lc_index, int acl_index) static void make_ip6_address_mask(ip6_address_t *addr, u8 prefix_len) { + ASSERT (prefix_len <= 128); ip6_address_mask_from_width(addr, prefix_len); } - -/* Maybe should be moved into the core somewhere */ -always_inline void -ip4_address_mask_from_width (ip4_address_t * a, u32 width) -{ - int i, byte, bit, bitnum; - ASSERT (width <= 32); - clib_memset (a, 0, sizeof (a[0])); - for (i = 0; i < width; i++) - { - bitnum = (7 - (i & 7)); - byte = i / 8; - bit = 1 << bitnum; - a->as_u8[byte] |= bit; - } -} - - static void make_ip4_address_mask(ip4_address_t *addr, u8 prefix_len) { - ip4_address_mask_from_width(addr, prefix_len); + ASSERT (prefix_len <= 32); + ip4_preflen_to_mask (prefix_len, addr); } static void diff --git a/src/plugins/dev_octeon/crypto.c b/src/plugins/dev_octeon/crypto.c index cc0b07329a3..52c796089d5 100644 --- a/src/plugins/dev_octeon/crypto.c +++ b/src/plugins/dev_octeon/crypto.c @@ -1940,7 +1940,7 @@ oct_init_crypto_engine_handlers (vlib_main_t *vm, vnet_dev_t *dev) } int -oct_conf_sw_queue (vlib_main_t *vm, vnet_dev_t *dev) +oct_conf_sw_queue (vlib_main_t *vm, vnet_dev_t *dev, oct_crypto_dev_t *ocd) { oct_crypto_main_t *ocm = &oct_crypto_main; vlib_thread_main_t *tm = vlib_get_thread_main (); @@ -1961,7 +1961,7 @@ oct_conf_sw_queue (vlib_main_t *vm, vnet_dev_t *dev) * Each pending queue will get number of cpt desc / number of cores. * And that desc count is shared across inflight entries. */ - n_inflight_req = (OCT_CPT_LF_MAX_NB_DESC / tm->n_vlib_mains); + n_inflight_req = (ocd->n_desc / tm->n_vlib_mains); for (i = 0; i < tm->n_vlib_mains; ++i) { diff --git a/src/plugins/dev_octeon/crypto.h b/src/plugins/dev_octeon/crypto.h index 5bd26f6b9be..4d8c56a314c 100644 --- a/src/plugins/dev_octeon/crypto.h +++ b/src/plugins/dev_octeon/crypto.h @@ -11,6 +11,9 @@ #define OCT_MAX_N_CPT_DEV 2 +#define OCT_CPT_LF_DEF_NB_DESC 16384 + +#define OCT_CPT_LF_MIN_NB_DESC 1024 #define OCT_CPT_LF_MAX_NB_DESC 128000 /* CRYPTO_ID, KEY_LENGTH_IN_BYTES, TAG_LEN, AAD_LEN */ @@ -81,6 +84,7 @@ typedef struct struct roc_cpt_lmtline lmtline; struct roc_cpt_lf lf; vnet_dev_t *dev; + u32 n_desc; } oct_crypto_dev_t; typedef struct @@ -211,5 +215,6 @@ vnet_crypto_async_frame_t *oct_crypto_frame_dequeue (vlib_main_t *vm, u32 *nb_elts_processed, u32 *enqueue_thread_idx); int oct_init_crypto_engine_handlers (vlib_main_t *vm, vnet_dev_t *dev); -int oct_conf_sw_queue (vlib_main_t *vm, vnet_dev_t *dev); +int oct_conf_sw_queue (vlib_main_t *vm, vnet_dev_t *dev, + oct_crypto_dev_t *ocd); #endif /* _CRYPTO_H_ */ diff --git a/src/plugins/dev_octeon/init.c b/src/plugins/dev_octeon/init.c index 561cbe94fed..69fb097e91f 100644 --- a/src/plugins/dev_octeon/init.c +++ b/src/plugins/dev_octeon/init.c @@ -61,6 +61,22 @@ static struct #undef _ }; +static vnet_dev_arg_t oct_dev_args[] = { + { + .id = OCT_DEV_ARG_CRYPTO_N_DESC, + .name = "n_desc", + .desc = "number of cpt descriptors, applicable to cpt devices only", + .type = VNET_DEV_ARG_TYPE_UINT32, + .default_val.uint32 = OCT_CPT_LF_DEF_NB_DESC, + }, + { + .id = OCT_DEV_ARG_END, + .name = "end", + .desc = "Argument end", + .type = VNET_DEV_ARG_END, + }, +}; + static u8 * oct_probe (vlib_main_t *vm, vnet_dev_bus_index_t bus_index, void *dev_info) { @@ -241,7 +257,7 @@ oct_conf_cpt_queue (vlib_main_t *vm, vnet_dev_t *dev, oct_crypto_dev_t *ocd) cpt_lf = &ocd->lf; cpt_lmtline = &ocd->lmtline; - cpt_lf->nb_desc = OCT_CPT_LF_MAX_NB_DESC; + cpt_lf->nb_desc = ocd->n_desc; cpt_lf->lf_id = 0; if ((rrv = roc_cpt_lf_init (roc_cpt, cpt_lf)) < 0) return cnx_return_roc_err (dev, rrv, "roc_cpt_lf_init"); @@ -261,6 +277,7 @@ oct_init_cpt (vlib_main_t *vm, vnet_dev_t *dev) extern oct_plt_init_param_t oct_plt_init_param; oct_device_t *cd = vnet_dev_get_data (dev); oct_crypto_dev_t *ocd = NULL; + u32 n_desc; int rrv; if (ocm->n_cpt == OCT_MAX_N_CPT_DEV || ocm->started) @@ -274,6 +291,27 @@ oct_init_cpt (vlib_main_t *vm, vnet_dev_t *dev) ocd->roc_cpt->pci_dev = &cd->plt_pci_dev; ocd->dev = dev; + ocd->n_desc = OCT_CPT_LF_DEF_NB_DESC; + + foreach_vnet_dev_args (arg, dev) + { + if (arg->id == OCT_DEV_ARG_CRYPTO_N_DESC && + vnet_dev_arg_get_uint32 (arg)) + { + n_desc = vnet_dev_arg_get_uint32 (arg); + if (n_desc < OCT_CPT_LF_MIN_NB_DESC || + n_desc > OCT_CPT_LF_MAX_NB_DESC) + { + log_err (dev, + "number of cpt descriptors should be within range " + "of %u and %u", + OCT_CPT_LF_MIN_NB_DESC, OCT_CPT_LF_MAX_NB_DESC); + return VNET_DEV_ERR_NOT_SUPPORTED; + } + + ocd->n_desc = vnet_dev_arg_get_uint32 (arg); + } + } if ((rrv = roc_cpt_dev_init (ocd->roc_cpt))) return cnx_return_roc_err (dev, rrv, "roc_cpt_dev_init"); @@ -290,7 +328,7 @@ oct_init_cpt (vlib_main_t *vm, vnet_dev_t *dev) * Initialize s/w queues, which are common across multiple * crypto devices */ - oct_conf_sw_queue (vm, dev); + oct_conf_sw_queue (vm, dev, ocd); ocm->crypto_dev[0] = ocd; } @@ -396,6 +434,7 @@ VNET_DEV_REGISTER_DRIVER (octeon) = { .free = oct_free, .probe = oct_probe, }, + .args = oct_dev_args, }; static clib_error_t * diff --git a/src/plugins/dev_octeon/octeon.h b/src/plugins/dev_octeon/octeon.h index ccf8f62880d..0cf937528f0 100644 --- a/src/plugins/dev_octeon/octeon.h +++ b/src/plugins/dev_octeon/octeon.h @@ -25,6 +25,12 @@ typedef enum { + OCT_DEV_ARG_CRYPTO_N_DESC = 1, + OCT_DEV_ARG_END, +} oct_dev_args_t; + +typedef enum +{ OCT_DEVICE_TYPE_UNKNOWN = 0, OCT_DEVICE_TYPE_RVU_PF, OCT_DEVICE_TYPE_RVU_VF, diff --git a/src/vat2/main.c b/src/vat2/main.c index bf415854db1..2949c4899aa 100644 --- a/src/vat2/main.c +++ b/src/vat2/main.c @@ -253,16 +253,15 @@ print_help (void) "Send API message to VPP and print reply\n" "\n" "-d, --debug Print additional information\n" - "-p, --prefix <prefix> Specify shared memory prefix to connect " - "to a given VPP instance\n" + "--dump-apis List all APIs available in VAT2 (might " + "not reflect running VPP)\n" "-f, --file <filename> File containing a JSON object with the " "arguments for the message to send\n" + "-p, --plugin-path Plugin path\n" + "-s, --prefix <prefix> Specify shared memory prefix to connect " + "to a given VPP instance\n" "-t, --template <message-name> Print a template JSON object for given API" - " message\n" - "--dump-apis List all APIs available in VAT2 (might " - "not reflect running VPP)\n" - "--plugin-path Pluing path" - "\n"; + " message\n"; printf ("%s", help_string); } @@ -281,38 +280,38 @@ main (int argc, char **argv) char *msgname = 0; static struct option long_options[] = { { "debug", no_argument, 0, 'd' }, - { "prefix", required_argument, 0, 's' }, - { "file", required_argument, 0, 'f' }, { "dump-apis", no_argument, 0, 0 }, - { "template", required_argument, 0, 't' }, + { "file", required_argument, 0, 'f' }, { "plugin-path", required_argument, 0, 'p' }, + { "prefix", required_argument, 0, 's' }, + { "template", required_argument, 0, 't' }, { 0, 0, 0, 0 } }; - while ((c = getopt_long (argc, argv, "hdp:f:t:", long_options, + while ((c = getopt_long (argc, argv, "df:p:s:t:", long_options, &option_index)) != -1) { switch (c) { case 0: - if (option_index == 3) + if (option_index == 1) dump_api = true; break; case 'd': vat2_debug = true; break; - case 't': - template = optarg; - break; - case 's': - prefix = optarg; - break; case 'f': filename = optarg; break; case 'p': pluginpath = optarg; break; + case 's': + prefix = optarg; + break; + case 't': + template = optarg; + break; case '?': print_help (); return 1; |