[dpdk-dev] [PATCH v4] drivers/net:new PMD using tun/tap host interface
Ferruh Yigit
ferruh.yigit at intel.com
Tue Oct 11 14:28:40 CEST 2016
On 10/4/2016 3:45 PM, Keith Wiles wrote:
> +/*
> + * Open a TAP interface device.
> + */
> +static int
> +rte_pmd_tap_devinit(const char *name, const char *params)
> +{
> + int ret = 0;
> + struct rte_kvargs *kvlist;
> + struct tap_info tap_info;
> +
> + /* Setup default values */
> + memset(&tap_info, 0, sizeof(tap_info));
> +
> + tap_info.speed = ETH_SPEED_NUM_10G;
> + snprintf(tap_info.name, sizeof(tap_info.name), "dtap%d", tap_unit++);
> +
> + if ((params == NULL) || (params[0] == '\0')) {
> + RTE_LOG(INFO, PMD, "Initializing pmd_tap for %s\n", name);
> +
> + ret = eth_dev_tap_create(name, &tap_info);
> + goto leave;
> + }
> +
> + RTE_LOG(INFO, PMD, "Initialize %s with params (%s)\n", name, params);
> +
> + kvlist = rte_kvargs_parse(params, valid_arguments);
> + if (!kvlist) {
> + ret = eth_dev_tap_create(name, &tap_info);
> + goto leave;
> + }
> +
> + if (rte_kvargs_count(kvlist, ETH_TAP_SPEED_ARG) == 1) {
> + ret = rte_kvargs_process(kvlist, ETH_TAP_SPEED_ARG,
> + &set_interface_speed, &tap_info);
> + if (ret < 0)
> + goto leave;
> + } else
> + set_interface_speed(NULL, NULL, &tap_info);
> +
> + if (rte_kvargs_count(kvlist, ETH_TAP_IFACE_ARG) == 1) {
> + ret = rte_kvargs_process(kvlist, ETH_TAP_IFACE_ARG,
> + &set_interface_name, &tap_info);
> + if (ret < 0)
> + goto leave;
> + } else
> + set_interface_name(NULL, NULL, (void *)&tap_info);
Also there must be a eth_dev_tap_create() call after this point to use
tap_info struct with custom values, right?
"--vdev eth_tap0,iface=foo0" parameter shouldn't be working with this
code, right?
> +
> + rte_kvargs_free(kvlist);
> +
> +leave:
> + if (ret == -1)
> + RTE_LOG(INFO, PMD, "Failed to create pmd_tap for %s\n", name);
> +
> + return ret;
> +}
More information about the dev
mailing list