@@ -76,6 +76,7 @@
#include <rte_eth_ctrl.h>
#include <rte_flow.h>
#include <rte_gro.h>
+#include <rte_port_representor.h>
#include <cmdline_rdline.h>
#include <cmdline_parse.h>
@@ -881,6 +882,12 @@ static void cmd_help_long_parsed(void *parsed_result,
"port config (port_id) pctype mapping update"
" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
" Update a flow type to pctype mapping item on a port\n\n"
+
+ "port representor add (pf_address) (vport_id)\n"
+ " Add port representor on PF with VF id\n\n"
+
+ "port representor del (pf_address) (vport_id)\n"
+ " Remove port representor on PF with VF id\n\n"
);
}
@@ -15552,6 +15559,79 @@ cmdline_parse_inst_t cmd_load_from_file = {
},
};
+struct cmd_port_representor_result {
+ cmdline_fixed_string_t cmd;
+ cmdline_fixed_string_t op;
+ cmdline_fixed_string_t action;
+ cmdline_fixed_string_t pf;
+ uint16_t vport;
+};
+
+cmdline_parse_token_string_t cmd_portrepresentor_cmd =
+TOKEN_STRING_INITIALIZER(struct cmd_port_representor_result,
+ cmd, "port");
+
+cmdline_parse_token_string_t cmd_portrepresentor_op =
+TOKEN_STRING_INITIALIZER(struct cmd_port_representor_result,
+ op, "representor");
+
+cmdline_parse_token_string_t cmd_portrepresentor_act =
+TOKEN_STRING_INITIALIZER(struct cmd_port_representor_result,
+ action, "add#del");
+
+cmdline_parse_token_string_t cmd_portrepresentor_pf =
+TOKEN_STRING_INITIALIZER(struct cmd_port_representor_result,
+ pf, NULL);
+
+cmdline_parse_token_num_t cmd_portrepresentor_vport =
+TOKEN_NUM_INITIALIZER(struct cmd_port_representor_result,
+ vport, UINT16);
+
+static void cmd_port_representor_callback(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_port_representor_result *res = parsed_result;
+ uint16_t port_id;
+ int ret;
+
+ printf("%s(): action:%s addr:%s vport:%i\n", __func__,
+ res->action, res->pf, res->vport);
+ if (strcmp("add", res->action) == 0) {
+ ret = rte_representor_port_register(res->pf, res->vport,
+ &port_id);
+ if (ret != 0)
+ printf("Registering port representor failed\n");
+ else
+ printf("Port Representor registered with port id %i\n",
+ port_id);
+ } else {
+ /* assume 'del' */
+ ret = rte_representor_port_unregister(res->pf, res->vport);
+ if (ret != 0)
+ printf("Port %i is not a valid port representor.\n",
+ res->vport);
+
+ }
+}
+
+
+cmdline_parse_inst_t cmd_port_representor = {
+ .f = cmd_port_representor_callback,
+ .help_str = "port representor add|del <BusName_DomBDF> <vport_id> "
+ "Add or remove a Port Representor",
+ .data = NULL,
+ .tokens = {
+ (void *)&cmd_portrepresentor_cmd,
+ (void *)&cmd_portrepresentor_op,
+ (void *)&cmd_portrepresentor_act,
+ (void *)&cmd_portrepresentor_pf,
+ (void *)&cmd_portrepresentor_vport,
+ NULL
+ }
+};
+
+
/* ******************************************************************************** */
/* list of instructions */
@@ -15593,6 +15673,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *) &cmd_show_bonding_config,
(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
+ (cmdline_parse_inst_t *) &cmd_port_representor,
(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
(cmdline_parse_inst_t *) &cmd_create_bonded_device,
(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
@@ -3654,3 +3654,29 @@ Validate and create a QinQ rule on port 0 to steer traffic to a queue on the hos
ID Group Prio Attr Rule
0 0 0 i- ETH VLAN VLAN=>VF QUEUE
1 0 0 i- ETH VLAN VLAN=>PF QUEUE
+
+Port Representors
+-----------------
+
+Adding and removal of port representors (*rte_representor*) is done via the
+``port representor add`` and ``port representor del`` commands. Once created
+these can take the same control commands as the underlying VF (Virtual
+Function).
+
+
+Adding a representor
+~~~~~~~~~~~~~~~~~~~~
+
+Adding a representor for a VF requires specifying the PF in
+``Bus_DomBDF`` format alongside the index number of the VF::
+
+ testpmd> port representor add pci_0000:81:00.0 0
+
+
+Removing a representor
+~~~~~~~~~~~~~~~~~~~~~~
+
+To remove a representor, the same parameters are required as were used to
+create it::
+
+ testpmd> port representor del pci_0000:81:00.0 0