Skip to content

Commit

Permalink
Merge branch 'main' into hotfix_k8s_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
maryamtahhan authored May 1, 2024
2 parents f772a94 + fd522d2 commit a9ee696
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 43 deletions.
2 changes: 1 addition & 1 deletion ansible/cndp-config/templates/fwd.jsonc.j2
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
// skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false
// description - (O) the description, 'desc' can be used as well
// xsk_pin_path - (O) Path to pinned bpf map
// uds_path - (O) Path to unix domain socket to get xsk map fd
"lports": {
{% for i in range(num_lports) %}
"{{iface}}:{{i}}": {
Expand Down Expand Up @@ -129,7 +130,6 @@
// no-restapi - (O) Disable RestAPI support
// cli - (O) Enable/Disable CLI supported
// mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, acl-strict, acl-permissive
// uds_path - (O) Path to unix domain socket to get xsk map fd
"options": {
"pkt_api": "xskdev",
"no-metrics": false,
Expand Down
7 changes: 6 additions & 1 deletion doc/guides/rel_notes/known_issues.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.. SPDX-License-Identifier: BSD-3-Clause
Copyright (c) 2010-2023 Intel Corporation.
Copyright (c) 2010-2024 Intel Corporation.
Known Issues and Limitations in Legacy Releases
===============================================

This section describes known issues with the CNDP software that aren't covered in the version specific release notes sections.

* `uds_path`` not supported through lport-group configuration. Support needs to be added for `uds_base_dir` and `uds_name`
so that the `uds_path` can be generated on a per port basis.
* `xsk_pin_path` not supported through lport-group configuration. Support needs to be added for `pin_path_base_dir` and `map_name`
so that the `xsk_pin_path` can be generated on a per port basis.
4 changes: 2 additions & 2 deletions doc/guides/sample_app_ug/cndpfwd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ The configuration json file is located in the ``cndpfwd`` example sub-directory
// skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false
// description - (O) the description, 'desc' can be used as well
// xsk_pin_path - (O) Path to pinned xsk map for this port
// uds_path - (0) Path to unix domain socket to get xsk map fd
"lports": {
"eth0:0": {
"pmd": "net_af_xdp",
Expand Down Expand Up @@ -200,8 +201,7 @@ The configuration json file is located in the ``cndpfwd`` example sub-directory
// no-restapi - (O) Disable RestAPI support
// cli - (O) Enable/Disable CLI supported
// mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, tx-only-rx
// acl-strict, acl-permissive
// uds_path - (0) Path to unix domain socket to get xsk map fd
// acl-strict, acl-permissiv
"options": {
"pkt_api": "xskdev",
"no-metrics": false,
Expand Down
2 changes: 1 addition & 1 deletion examples/cndp-frr/docker/cnetfrr-graph.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
// force_wakeup - (O) force TX wakeup calls for CVL NIC, default false
// skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false
// xsk_pin_path - (O) Path to pinned xsk map for this port
// uds_path - (0) Path to unix domain socket to get xsk map fd
// description - (O) the description, 'desc' can be used as well
"lports": {
"eth0:0": {
Expand Down Expand Up @@ -125,7 +126,6 @@
// no-restapi - (O) Disable RestAPI support
// cli - (O) Enable/Disable CLI supported
// mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, acl-strict, acl-permissive
// uds_path - (O) Path to unix domain socket to get xsk map fd
"options": {
"no-metrics": false,
"no-restapi": false,
Expand Down
1 change: 1 addition & 0 deletions examples/cndpfwd/fwd.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
// force_wakeup - (O) force TX wakeup calls for CVL NIC, default false
// skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false
// xsk_pin_path - (O) Path to pinned xsk map for this port
// uds_path - (O) Path to unix domain socket to get xsk map fd
// description - (O) the description, 'desc' can be used as well
"lports": {
"eth0:0": {
Expand Down
1 change: 0 additions & 1 deletion examples/cndpfwd/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ enum {
#define NO_RESTAPI_TAG "no-restapi" /**< json tag for no-restapi */
#define ENABLE_CLI_TAG "cli" /**< json tag to enable/disable CLI */
#define MODE_TAG "mode" /**< json tag to set the mode flag */
#define UDS_PATH_TAG "uds_path" /**< json tag for UDS to get xsk map fd */
#define FIB_RULES_TAG "l3fwd-fib-rules" /**< json tag to set up static FIB entries */
#define HS_PATTERN_TAG "hs-patterns" /**< json tag for Hyperscan patterns */

Expand Down
15 changes: 6 additions & 9 deletions examples/cndpfwd/parse-args.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ process_callback(jcfg_info_t *j __cne_unused, void *_obj, void *arg, int idx)
if (f->test == UNKNOWN_TEST)
f->test = get_app_mode(f->opts.mode);
}
} else if (!strncmp(obj.opt->name, UDS_PATH_TAG, nlen)) {
if (obj.opt->val.type == STRING_OPT_TYPE) {
f->xdp_uds = udsc_handshake(obj.opt->val.str);
if (f->xdp_uds == NULL)
CNE_ERR_RET("UDS handshake failed %s\n", strerror(errno));
}
} else if (!strncmp(obj.opt->name, FIB_RULES_TAG, nlen)) {
if (obj.opt->val.type == ARRAY_OPT_TYPE) {
f->fib_rules = calloc(obj.opt->val.array_sz, sizeof(char *));
Expand Down Expand Up @@ -201,10 +195,13 @@ process_callback(jcfg_info_t *j __cne_unused, void *_obj, void *arg, int idx)
pcfg.xsk_map_path = lport->xsk_map_path;
}

if (f->xdp_uds) {
if (lport->uds_path) {
cne_printf("[yellow]**** [green]UDS is [red]enabled[]\n");
pcfg.xsk_uds = f->xdp_uds;
pcfg.flags |= LPORT_UNPRIVILEGED;
pcfg.xsk_uds = f->xdp_uds = udsc_handshake(lport->uds_path);
if (pcfg.xsk_uds == NULL) {
pd->xsk = NULL;
CNE_ERR_RET("UDS handshake failed %s\n", strerror(errno));
}
}

pcfg.addr = jcfg_lport_region(lport, &pcfg.bufcnt);
Expand Down
2 changes: 1 addition & 1 deletion examples/cnet-graph/cnetfwd-graph.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
// force_wakeup - (O) force TX wakeup calls for CVL NIC, default false
// skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false
// xsk_pin_path - (O) Path to pinned xsk map for this port
// uds_path - (O) Path to unix domain socket to get xsk map fd
// description - (O) the description, 'desc' can be used as well
"lports": {
"eth0:0": {
Expand Down Expand Up @@ -124,7 +125,6 @@
// no-restapi - (O) Disable RestAPI support
// cli - (O) Enable/Disable CLI supported
// mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, acl-strict, acl-permissive
// uds_path - (O) Path to unix domain socket to get xsk map fd
"options": {
"no-metrics": false,
"no-restapi": false,
Expand Down
1 change: 1 addition & 0 deletions lib/common/uds_connect/uds_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ udsc_handshake(const char *uds_name)
* to register protocol commands with and process information
* exchanged on the UDS.
*/

info = uds_connect(uds_name, &err_msg, NULL);
if (!info)
return NULL;
Expand Down
3 changes: 2 additions & 1 deletion lib/core/xskdev/xskdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,10 +930,11 @@ xskdev_socket_destroy(xskdev_info_t *xi)
uint32_t curr_prog_id = 0;

if (xi) {
CNE_DEBUG("ifindex %d, %s, prog_id %u\n", xi->if_index, xi->ifname, xi->prog_id);
if (xi->if_index) {
if (!xi->xsk_map_fd) { // Don't unload programs we didn't load.
if (xi->unprivileged == 0) {
CNE_DEBUG("ifindex %d, %s, prog_id %u\n", xi->if_index, xi->ifname,
xi->prog_id);
#if USE_LIBBPF_8
if (bpf_xdp_query_id(xi->if_index, xi->xdp_flags, &curr_prog_id))
#else
Expand Down
4 changes: 3 additions & 1 deletion lib/usr/app/jcfg/jcfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#define DEFAULT_CHUNK_SIZE 1024
#define UMEM_MAX_REGIONS 128
#define JCFG_MAX_STRING_SIZE 32
#define JCFG_MAX_STRING_SIZE 64

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -173,6 +173,7 @@ typedef struct jcfg_lport {
uint16_t busy_budget; /**< busy budget 0xFFFF disabled, 0 use default, >0 budget */
uint16_t flags; /**< Flags to configure lport in lport_cfg_t.flags in cne_lport.h */
char *xsk_map_path; /**< The path to the pinned xsk_map for this port */
char *uds_path; /**< The path to the pinned xsk_map for this port */
} jcfg_lport_t;

/** JCFG lport configuration names */
Expand All @@ -187,6 +188,7 @@ typedef struct jcfg_lport {
#define JCFG_LPORT_BUSY_TIMEOUT_NAME "busy_timeout"
#define JCFG_LPORT_BUSY_BUDGET_NAME "busy_budget"
#define JCFG_PINNED_XSK_MAP_NAME "xsk_pin_path"
#define JCFG_UDS_NAME "uds_path"
#define JCFG_LPORT_FORCE_WAKEUP_NAME "force_wakeup"
#define JCFG_LPORT_SKB_MODE_NAME "skb_mode"

Expand Down
3 changes: 3 additions & 0 deletions lib/usr/app/jcfg/jcfg_lport.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ _lport(struct json_object *obj, int flags, struct json_object *parent __cne_unus
} else if (!strncmp(key, JCFG_PINNED_XSK_MAP_NAME, keylen)) {
lport->xsk_map_path = strndup(json_object_get_string(obj), JCFG_MAX_STRING_SIZE);
lport->flags |= LPORT_UNPRIVILEGED;
} else if (!strncmp(key, JCFG_UDS_NAME, keylen)) {
lport->uds_path = strndup(json_object_get_string(obj), JCFG_MAX_STRING_SIZE);
lport->flags |= LPORT_UNPRIVILEGED;
} else if (!strncmp(key, JCFG_LPORT_FORCE_WAKEUP_NAME, keylen))
lport->flags |= json_object_get_boolean(obj) ? LPORT_FORCE_WAKEUP : 0;
else if (!strncmp(key, JCFG_LPORT_SKB_MODE_NAME, keylen))
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ if nl_cli_dep.found()
endif

nl_route_dep = dependency('libnl-route-3.0', required: true, method: 'pkg-config', static: use_static_libs)
if nl_cli_dep.found()
if nl_route_dep.found()
add_project_link_arguments('-lnl-route-3', language: 'c')
extra_ldflags += '-lnl-route-3'
endif
Expand Down
10 changes: 5 additions & 5 deletions tools/cndp.schema
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@
"description": "The path to which the xskmap has been pinned outside of cndp",
"type": "string",
"default": false
},
"uds_path": {
"description": "The path to socket cndp can connect to to retrieve the xskmap fd",
"type": "string",
"default": false
}
},
"patternProperties": {
Expand Down Expand Up @@ -339,11 +344,6 @@
"description": "Enable XDP_FLAGS_SKB_MODE to force copy mode",
"type": "boolean",
"default": false
},
"xsk_pin_path": {
"description": "The path to which the xskmap has been pinned outside of cndp",
"type": "string",
"default": false
}
},
"patternProperties": {
Expand Down
46 changes: 29 additions & 17 deletions tools/jsonc_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
# would populate the AFXDP_DEVICES environment variable.
# The available cores to the application are determined by
# the 'lscpu' command.

num_of_devs=0
KIND=false
PINNED_BPF_MAP=false
config_file=config.jsonc
AFXDP_DEVICES=${AFXDP_DEVICES:-net1}
AFXDP_COPY_MODE=${AFXDP_COPY_MODE:-false}
config_file=config.jsonc
declare -a AFXDP_DEVICES
declare -a MAP_OR_UDS_PATH=()
declare -a MAP_OR_UDS=()

while getopts "kp" flag; do
case $flag in
Expand All @@ -32,16 +34,28 @@ else
DEFAULT_QID=0 # For kind using veth use queue 0
fi

if [ ${PINNED_BPF_MAP} = false ] ; then
UDS_PATH="uds_path"
UDS="/tmp/afxdp.sock"
UDS_CFG=("\"$UDS_PATH\": \"$UDS\",")
unset "${MAP_CFG[@]}"
else
MAP_PATH="xsk_pin_path"
MAP="/tmp/xsks_map"
MAP_CFG=("\"$MAP_PATH\": \"$MAP\",")
unset "${UDS_CFG[@]}"
for device in "${!AFXDP_DEVICES_@}";
do
AFXDP_DEVICES[num_of_devs]="${!device}"
if [ ${PINNED_BPF_MAP} = false ] ; then
MAP_OR_UDS[num_of_devs]="\"uds_path\""
MAP_OR_UDS_PATH[num_of_devs]="\"/tmp/afxdp_dp/${!device}/afxdp.sock\""
else
MAP_OR_UDS[num_of_devs]="\"xsk_pin_path\""
MAP_OR_UDS_PATH[num_of_devs]="\"/tmp/afxdp_dp/${!device}/xsks_map\""
fi
num_of_devs=$((num_of_devs+1))
done

if [ $num_of_devs == 0 ] ; then
AFXDP_DEVICES+=("net1")
if [ ${PINNED_BPF_MAP} = false ] ; then
MAP_OR_UDS[num_of_devs]="uds_path"
MAP_OR_UDS_PATH[num_of_devs]="/tmp/afxdp_dp/${AFXDP_DEVICES[num_of_devs]}/afxdp.sock"
else
MAP_OR_UDS[num_of_devs]="xsk_pin_path"
MAP_OR_UDS_PATH[num_of_devs]="/tmp/afxdp_dp//${AFXDP_DEVICES[num_of_devs]}/xsks_map"
fi
fi

num_of_interfaces=0
Expand All @@ -54,7 +68,7 @@ declare -a num_of_cores_in_each_numa_node
declare -a LCORE

# get list of interfaces
for net in $AFXDP_DEVICES
for net in "${AFXDP_DEVICES[@]}"
do
NET[num_of_interfaces++]=$net
QID[num_of_qids++]=${DEFAULT_QID}
Expand Down Expand Up @@ -129,7 +143,7 @@ EOF
"umem": "umem0",
"region": ${i},
"skb_mode": ${AFXDP_COPY_MODE},
${MAP_CFG[@]}
${MAP_OR_UDS[i]} : ${MAP_OR_UDS_PATH[i]},
"description": "LAN ${i} port"
}
EOF
Expand Down Expand Up @@ -273,13 +287,11 @@ cat <<-EOF > ${config_file}
// no-restapi - (O) Disable RestAPI support
// cli - (O) Enable/Disable CLI supported
// mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, acl-strict, acl-permissive
// uds_path - (O) Path to unix domain socket to get xsk map fd
"options": {
"pkt_api": "xskdev",
"no-metrics": false,
"no-restapi": false,
"cli": false,
${UDS_CFG[@]}
"mode": "drop",
// FIB rules <IP Address>,<Destination MAC>,<destination port>
"l3fwd-fib-rules": [
Expand Down
1 change: 0 additions & 1 deletion tools/jsonc_gen_lport_groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ function emit_jsonc_options
cat <<-EOF >> $config_file
"options": {
"uds_path": "/tmp/cndp.sock",
"mode": "drop"
}
}
Expand Down
2 changes: 1 addition & 1 deletion usrtools/xskmap_load_send/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ application to be used alongside this utility is shown below:
"umem": "umem0",
"region": 0,
"description": "LAN 0 port",
"uds_path": "/var/run/cndp/app_socket.580113"
}
},
...
Expand All @@ -31,7 +32,6 @@ application to be used alongside this utility is shown below:
"no-restapi": false,
"cli": true,
"mode": "drop",
"uds_path": "/var/run/cndp/app_socket.580113"
},
...
```
Expand Down

0 comments on commit a9ee696

Please sign in to comment.