X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fl2fwd-crypto%2Fmain.c;h=949219357d80bd7e14b69127da10c3bd23f1342e;hb=6104a5224d9b263297aa7c88aab8ba099202b676;hp=15fab102bf7f411a54db48985fde18c84a3a0377;hpb=60da774e6e59ea1d4eee324920c1fb56af00d17e;p=dpdk.git diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index 15fab102bf..949219357d 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -167,6 +167,8 @@ struct l2fwd_crypto_options { uint16_t block_size; char string_type[MAX_STR_LEN]; + + uint64_t cryptodev_mask; }; /** l2fwd crypto lcore params */ @@ -470,6 +472,10 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m, op->sym->auth.aad.data = cparams->aad.data; op->sym->auth.aad.phys_addr = cparams->aad.phys_addr; op->sym->auth.aad.length = cparams->aad.length; + } else { + op->sym->auth.aad.data = NULL; + op->sym->auth.aad.phys_addr = 0; + op->sym->auth.aad.length = 0; } } @@ -670,7 +676,8 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options) generate_random_key(port_cparams[i].aad.data, port_cparams[i].aad.length); - } + } else + port_cparams[i].aad.length = 0; if (options->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) port_cparams[i].hash_verify = 1; @@ -781,7 +788,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options) ops_burst, nb_rx) != nb_rx) { for (j = 0; j < nb_rx; j++) - rte_pktmbuf_free(pkts_burst[i]); + rte_pktmbuf_free(pkts_burst[j]); nb_rx = 0; } @@ -852,7 +859,8 @@ l2fwd_crypto_usage(const char *prgname) " --aad_random_size SIZE: size of AAD when generated randomly\n" " --digest_size SIZE: size of digest to be generated/verified\n" - " --sessionless\n", + " --sessionless\n" + " --cryptodev_mask MASK: hexadecimal bitmask of crypto devices to configure\n", prgname); } @@ -996,6 +1004,27 @@ parse_auth_op(enum rte_crypto_auth_operation *op, char *optarg) return -1; } +static int +parse_cryptodev_mask(struct l2fwd_crypto_options *options, + const char *q_arg) +{ + char *end = NULL; + uint64_t pm; + + /* parse hexadecimal string */ + pm = strtoul(q_arg, &end, 16); + if ((pm == '\0') || (end == NULL) || (*end != '\0')) + pm = 0; + + options->cryptodev_mask = pm; + if (options->cryptodev_mask == 0) { + printf("invalid cryptodev_mask specified\n"); + return -1; + } + + return 0; +} + /** Parse long options */ static int l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options, @@ -1096,6 +1125,9 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options, return 0; } + else if (strcmp(lgopts[option_index].name, "cryptodev_mask") == 0) + return parse_cryptodev_mask(options, optarg); + return -1; } @@ -1210,6 +1242,7 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options) options->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; options->type = CDEV_TYPE_ANY; + options->cryptodev_mask = UINT64_MAX; } static void @@ -1332,6 +1365,7 @@ l2fwd_crypto_parse_args(struct l2fwd_crypto_options *options, { "digest_size", required_argument, 0, 0 }, { "sessionless", no_argument, 0, 0 }, + { "cryptodev_mask", required_argument, 0, 0}, { NULL, 0, 0, 0 } }; @@ -1472,6 +1506,17 @@ check_type(struct l2fwd_crypto_options *options, struct rte_cryptodev_info *dev_ return -1; } +/* Check if the device is enabled by cryptodev_mask */ +static int +check_cryptodev_mask(struct l2fwd_crypto_options *options, + uint8_t cdev_id) +{ + if (options->cryptodev_mask & (1 << cdev_id)) + return 0; + + return -1; +} + static inline int check_supported_size(uint16_t length, uint16_t min, uint16_t max, uint16_t increment) @@ -1526,6 +1571,9 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports, } }; + if (check_cryptodev_mask(options, (uint8_t)cdev_id)) + continue; + rte_cryptodev_info_get(cdev_id, &dev_info); /* Set cipher parameters */ @@ -1657,7 +1705,6 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports, continue; } - options->block_size = cap->sym.auth.block_size; /* * Check if length of provided AAD is supported * by the algorithm chosen.