idpf: add native idpf driver plugin

Add a new native idpf driver. This patch enables the device
initialization. Add some necessary functions and definations
for input and output. A new version of virtchnl is introduced.

Type: feature

Signed-off-by: Ting Xu <ting.xu@intel.com>
Change-Id: Ibbd9cd645e64469f1c4c8b33346c1301be3f6927
This commit is contained in:
Ting Xu
2022-12-15 02:10:59 +00:00
committed by Dave Wallace
parent cc22d38100
commit 737edea328
15 changed files with 6249 additions and 0 deletions

View File

@ -571,6 +571,11 @@ M: Dave Barach <vpp@barachs.net>
M: Florin Coras <fcoras@cisco.com>
F: src/plugins/unittest/
Plugin - IDPF Device driver
I: idpf
M: Ting Xu <ting.xu@intel.com>
F: src/plugins/idpf/
Plugin - Intel DMA engines
I: dma_intel
M: Marvin Liu <yong.liu@intel.com>

View File

@ -469,6 +469,8 @@ IBverbs
iccrg
icmp
icmpr
idpf
Idpf
ietf
iface
ifndef

View File

@ -0,0 +1,28 @@
# Copyright (c) 2023 Intel and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
add_vpp_plugin(idpf
SOURCES
cli.c
device.c
format.c
plugin.c
idpf_controlq.c
idpf_api.c
API_FILES
idpf.api
API_TEST_SOURCES
idpf_test.c
)

View File

@ -0,0 +1,59 @@
Intel IDPF device driver
========================
Overview
--------
This plugins provides native device support for Intel Infrastructure
Data Path Function (IDPF). The current IDPF is a driver specification
for future Intel Physical Function devices. IDPF defines communication
channel between Data Plane (DP) and Control Plane (CP).
Prerequisites
-------------
- Driver requires MSI-X interrupt support, which is not supported by
uio_pci_generic driver, so vfio-pci needs to be used. On systems
without IOMMU vfio driver can still be used with recent kernels which
support no-iommu mode.
Known issues
------------
- This driver is still in experimental phase, and the corresponding device
is not released yet.
- Current version only supports device initialization. Basic I/O function
will be supported in the next release.
Usage
-----
Interface Creation
~~~~~~~~~~~~~~~~~~
Interfaces can be dynamically created by using following CLI:
::
create interface idpf 0000:4b:00.0 vport-num 1 rx-single 1 tx-single 1
set int state idpf-0/4b/0/0 up
vport-num: number of vport to be created. Each vport is related to one netdev.
rx-single: configure Rx queue mode, split queue mode by default.
tx-single: configure Tx queue mode, split queue mode by default.
Interface Deletion
~~~~~~~~~~~~~~~~~~
Interface can be deleted with following CLI:
::
delete interface idpf <interface name>
Interface Statistics
~~~~~~~~~~~~~~~~~~~~
Interface statistics can be displayed with
``sh hardware-interface <if-name>`` command.

135
src/plugins/idpf/cli.c Normal file
View File

@ -0,0 +1,135 @@
/*
*------------------------------------------------------------------
* Copyright (c) 2023 Intel and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*------------------------------------------------------------------
*/
#include <idpf/idpf.h>
static clib_error_t *
idpf_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;
idpf_create_if_args_t args;
u32 tmp;
clib_memset (&args, 0, sizeof (idpf_create_if_args_t));
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "%U", unformat_vlib_pci_addr, &args.addr))
;
else if (unformat (line_input, "rx-single %u", &tmp))
args.rxq_single = 1;
else if (unformat (line_input, "tx-single %u", &tmp))
args.txq_single = 1;
else if (unformat (line_input, "rxq-num %u", &tmp))
args.rxq_num = tmp;
else if (unformat (line_input, "txq-num %u", &tmp))
args.txq_num = tmp;
else if (unformat (line_input, "rxq-size %u", &tmp))
args.rxq_size = tmp;
else if (unformat (line_input, "txq-size %u", &tmp))
args.txq_size = tmp;
else if (unformat (line_input, "vport-num %u", &tmp))
args.req_vport_nb = tmp;
else if (unformat (line_input, "name %s", &args.name))
;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
unformat_free (line_input);
idpf_create_if (vm, &args);
vec_free (args.name);
return args.error;
}
VLIB_CLI_COMMAND (idpf_create_command, static) = {
.path = "create interface idpf",
.short_help = "create interface idpf <pci-address> "
"[vport <size>] [rx-single <size>] [tx-single <size>]",
.function = idpf_create_command_fn,
};
static clib_error_t *
idpf_delete_command_fn (vlib_main_t *vm, unformat_input_t *input,
vlib_cli_command_t *cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
u32 sw_if_index = ~0;
vnet_hw_interface_t *hw;
vnet_main_t *vnm = vnet_get_main ();
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "sw_if_index %d", &sw_if_index))
;
else if (unformat (line_input, "%U", unformat_vnet_sw_interface, vnm,
&sw_if_index))
;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
unformat_free (line_input);
if (sw_if_index == ~0)
return clib_error_return (0,
"please specify interface name or sw_if_index");
hw = vnet_get_sup_hw_interface_api_visible_or_null (vnm, sw_if_index);
if (hw == NULL || idpf_device_class.index != hw->dev_class_index)
return clib_error_return (0, "not an IDPF interface");
vlib_process_signal_event (vm, idpf_process_node.index,
IDPF_PROCESS_EVENT_DELETE_IF, hw->dev_instance);
return 0;
}
VLIB_CLI_COMMAND (idpf_delete_command, static) = {
.path = "delete interface idpf",
.short_help = "delete interface idpf "
"{<interface> | sw_if_index <sw_idx>}",
.function = idpf_delete_command_fn,
.is_mp_safe = 1,
};
clib_error_t *
idpf_cli_init (vlib_main_t *vm)
{
return 0;
}
VLIB_INIT_FUNCTION (idpf_cli_init);
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/

2265
src/plugins/idpf/device.c Normal file

File diff suppressed because it is too large Load Diff

77
src/plugins/idpf/format.c Normal file
View File

@ -0,0 +1,77 @@
/*
*------------------------------------------------------------------
* Copyright (c) 2023 Intel and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*------------------------------------------------------------------
*/
#include <idpf/idpf.h>
u8 *
format_idpf_device_name (u8 *s, va_list *args)
{
vlib_main_t *vm = vlib_get_main ();
u32 i = va_arg (*args, u32);
idpf_device_t *id = idpf_get_device (i);
vlib_pci_addr_t *addr = vlib_pci_get_addr (vm, id->pci_dev_handle);
if (id->name)
return format (s, "%s", id->name);
s = format (s, "idpf-%x/%x/%x/%x", addr->domain, addr->bus, addr->slot,
addr->function);
return s;
}
u8 *
format_idpf_device_flags (u8 *s, va_list *args)
{
idpf_device_t *id = va_arg (*args, idpf_device_t *);
u8 *t = 0;
#define _(a, b, c) \
if (id->flags & (1 << a)) \
t = format (t, "%s%s", t ? " " : "", c);
foreach_idpf_device_flags
#undef _
s = format (s, "%v", t);
vec_free (t);
return s;
}
u8 *
format_idpf_checksum_cap_flags (u8 *s, va_list *args)
{
u32 flags = va_arg (*args, u32);
int not_first = 0;
char *strs[32] = {
#define _(a, b, c) [a] = c,
foreach_idpf_checksum_cap_flag
#undef _
};
for (int i = 0; i < 32; i++)
{
if ((flags & (1 << i)) == 0)
continue;
if (not_first)
s = format (s, " ");
if (strs[i])
s = format (s, "%s", strs[i]);
else
s = format (s, "unknown(%u)", i);
not_first = 1;
}
return s;
}

80
src/plugins/idpf/idpf.api Normal file
View File

@ -0,0 +1,80 @@
/*
*------------------------------------------------------------------
* Copyright (c) 2023 Intel and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*------------------------------------------------------------------
*/
option version = "1.0.0";
import "vnet/interface_types.api";
/** \brief
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param pci_addr - pci address as unsigned 32bit integer:
0-15 domain, 16-23 bus, 24-28 slot, 29-31 function
ddddddddddddddddbbbbbbbbsssssfff
@param rxq_num - number of receive queues
@param rxq_size - receive queue size
@param txq_size - transmit queue size
*/
define idpf_create
{
u32 client_index;
u32 context;
u32 pci_addr;
u16 rxq_single;
u16 txq_single;
u16 rxq_num;
u16 txq_num;
u16 rxq_size;
u16 txq_size;
u16 req_vport_nb;
option vat_help = "<pci-address> [vport-num <size>] [rx-single <size>] [tx-single <size>] [rxq-num <size>] [txq-num <size>] [rxq-size <size>] [txq-size <size>]";
};
/** \brief
@param context - sender context, to match reply w/ request
@param retval - return value for request
@param sw_if_index - software index for the new idpf interface
*/
define idpf_create_reply
{
u32 context;
i32 retval;
vl_api_interface_index_t sw_if_index;
};
/** \brief
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param sw_if_index - interface index
*/
autoreply define idpf_delete
{
u32 client_index;
u32 context;
vl_api_interface_index_t sw_if_index;
option vat_help = "<sw_if_index>";
};
/*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/

929
src/plugins/idpf/idpf.h Normal file

File diff suppressed because it is too large Load Diff

111
src/plugins/idpf/idpf_api.c Normal file
View File

@ -0,0 +1,111 @@
/*
*------------------------------------------------------------------
* Copyright (c) 2023 Intel and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*------------------------------------------------------------------
*/
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlib/pci/pci.h>
#include <vnet/ethernet/ethernet.h>
#include <idpf/idpf.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
/* define message IDs */
#include <idpf/idpf.api_enum.h>
#include <idpf/idpf.api_types.h>
#define REPLY_MSG_ID_BASE (im->msg_id_base)
#include <vlibapi/api_helper_macros.h>
static void
vl_api_idpf_create_t_handler (vl_api_idpf_create_t *mp)
{
vlib_main_t *vm = vlib_get_main ();
idpf_main_t *im = &idpf_main;
vl_api_idpf_create_reply_t *rmp;
idpf_create_if_args_t args;
int rv;
clib_memset (&args, 0, sizeof (idpf_create_if_args_t));
args.addr.as_u32 = ntohl (mp->pci_addr);
args.rxq_single = ntohs (mp->rxq_single);
args.txq_single = ntohs (mp->txq_single);
args.rxq_num = ntohs (mp->rxq_num);
args.txq_num = ntohs (mp->txq_num);
args.rxq_size = ntohs (mp->rxq_size);
args.txq_size = ntohs (mp->txq_size);
args.req_vport_nb = ntohs (mp->req_vport_nb);
idpf_create_if (vm, &args);
rv = args.rv;
REPLY_MACRO2 (VL_API_IDPF_CREATE_REPLY,
({ rmp->sw_if_index = ntohl (args.sw_if_index); }));
}
static void
vl_api_idpf_delete_t_handler (vl_api_idpf_delete_t *mp)
{
vlib_main_t *vm = vlib_get_main ();
vnet_main_t *vnm = vnet_get_main ();
idpf_main_t *im = &idpf_main;
vl_api_idpf_delete_reply_t *rmp;
vnet_hw_interface_t *hw;
int rv = 0;
hw = vnet_get_sup_hw_interface_api_visible_or_null (vnm,
htonl (mp->sw_if_index));
if (hw == NULL || idpf_device_class.index != hw->dev_class_index)
{
rv = VNET_API_ERROR_INVALID_INTERFACE;
goto reply;
}
vlib_process_signal_event (vm, idpf_process_node.index,
IDPF_PROCESS_EVENT_DELETE_IF, hw->dev_instance);
reply:
REPLY_MACRO (VL_API_IDPF_DELETE_REPLY);
}
/* set tup the API message handling tables */
#include <idpf/idpf.api.c>
static clib_error_t *
idpf_plugin_api_hookup (vlib_main_t *vm)
{
idpf_main_t *ivm = &idpf_main;
api_main_t *am = vlibapi_get_main ();
/* ask for a correctly-sized block of API message decode slots */
ivm->msg_id_base = setup_message_id_table ();
vl_api_set_msg_thread_safe (am, ivm->msg_id_base + VL_API_IDPF_DELETE, 1);
return 0;
}
VLIB_API_INIT_FUNCTION (idpf_plugin_api_hookup);
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,169 @@
/*
*------------------------------------------------------------------
* Copyright (c) 2023 Intel and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*------------------------------------------------------------------
*/
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlib/pci/pci.h>
#include <vnet/ethernet/ethernet.h>
#include <vat/vat.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vppinfra/error.h>
#include <idpf/idpf.h>
#define __plugin_msg_base idpf_test_main.msg_id_base
#include <vlibapi/vat_helper_macros.h>
/* declare message IDs */
#include <idpf/idpf.api_enum.h>
#include <idpf/idpf.api_types.h>
typedef struct
{
/* API message ID base */
u16 msg_id_base;
vat_main_t *vat_main;
} idpf_test_main_t;
idpf_test_main_t idpf_test_main;
/* idpf create API */
static int
api_idpf_create (vat_main_t *vam)
{
unformat_input_t *i = vam->input;
vl_api_idpf_create_t *mp;
idpf_create_if_args_t args;
uint32_t tmp;
int ret;
u32 x[4];
clib_memset (&args, 0, sizeof (idpf_create_if_args_t));
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
if (unformat (i, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
{
args.addr.domain = x[0];
args.addr.bus = x[1];
args.addr.slot = x[2];
args.addr.function = x[3];
}
else if (unformat (i, "rx-single %u", &tmp))
args.rxq_single = 1;
else if (unformat (i, "tx-single %u", &tmp))
args.txq_single = 1;
else if (unformat (i, "rxq-size %u", &tmp))
args.rxq_size = tmp;
else if (unformat (i, "txq-size %u", &tmp))
args.txq_size = tmp;
else if (unformat (i, "rxq-num %u", &tmp))
args.rxq_num = tmp;
else if (unformat (i, "txq-num %u", &tmp))
args.txq_num = tmp;
else if (unformat (i, "vport-num %u", &tmp))
args.req_vport_nb = tmp;
else
{
clib_warning ("unknown input '%U'", format_unformat_error, i);
return -99;
}
}
M (IDPF_CREATE, mp);
mp->pci_addr = clib_host_to_net_u32 (args.addr.as_u32);
mp->rxq_single = clib_host_to_net_u16 (args.rxq_single);
mp->txq_single = clib_host_to_net_u16 (args.txq_single);
mp->rxq_num = clib_host_to_net_u16 (args.rxq_num);
mp->txq_num = clib_host_to_net_u16 (args.txq_num);
mp->rxq_size = clib_host_to_net_u16 (args.rxq_size);
mp->txq_size = clib_host_to_net_u16 (args.txq_size);
mp->req_vport_nb = clib_host_to_net_u16 (args.req_vport_nb);
S (mp);
W (ret);
return ret;
}
/* idpf-create reply handler */
static void
vl_api_idpf_create_reply_t_handler (vl_api_idpf_create_reply_t *mp)
{
vat_main_t *vam = idpf_test_main.vat_main;
i32 retval = ntohl (mp->retval);
if (retval == 0)
{
fformat (vam->ofp, "created idpf with sw_if_index %d\n",
ntohl (mp->sw_if_index));
}
vam->retval = retval;
vam->result_ready = 1;
vam->regenerate_interface_table = 1;
}
/* idpf delete API */
static int
api_idpf_delete (vat_main_t *vam)
{
unformat_input_t *i = vam->input;
vl_api_idpf_delete_t *mp;
u32 sw_if_index = 0;
u8 index_defined = 0;
int ret;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
if (unformat (i, "sw_if_index %u", &sw_if_index))
index_defined = 1;
else
{
clib_warning ("unknown input '%U'", format_unformat_error, i);
return -99;
}
}
if (!index_defined)
{
errmsg ("missing sw_if_index\n");
return -99;
}
M (IDPF_DELETE, mp);
mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
S (mp);
W (ret);
return ret;
}
#include <idpf/idpf.api_test.c>
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/

34
src/plugins/idpf/plugin.c Normal file
View File

@ -0,0 +1,34 @@
/*
*------------------------------------------------------------------
* Copyright (c) 2023 Intel and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*------------------------------------------------------------------
*/
#include <vlib/vlib.h>
#include <vnet/plugin/plugin.h>
#include <vpp/app/version.h>
VLIB_PLUGIN_REGISTER () = {
.version = VPP_BUILD_VER,
.description =
"Intel Infrastructure Data Path Function (IDPF) Device Driver",
};
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff