2 ################################################################################
3 # Copyright (c) 2016 Wind River Systems, Inc.
5 # SPDX-License-Identifier: Apache-2.0
7 ################################################################################
9 # Certain i40e network devices (XL710 Fortville) have an internal firmware LLDP
10 # agent enabled by default. This can prevent LLDP PDUs from being processed by
11 # the driver and any upper layer agents.
13 # This script allows a user to enable and disable the internal LLDP agent.
15 # Note: debugfs must be enabled in the kernel
18 # ./i40e-lldp-configure.sh start
21 # ./i40e-lldp-configure.sh stop
23 PROGNAME=$(basename $0)
24 DEBUGFS_PATH=/sys/kernel/debug
25 DEBUGFS_I40_DEVICES_PATH=$DEBUGFS_PATH/i40e
29 local MSG="${PROGNAME}: $1"
30 logger -p notice "${MSG}"
34 local MSG="${PROGNAME}: $1"
35 logger -p error "${MSG}"
38 function configure_device {
41 local DEVICE_PATH=${DEBUGFS_I40_DEVICES}/${DEVICE}
43 if [ ! -d ${DEVICE_PATH} ]; then
47 echo "${LLDP_COMMAND} ${ACTION}" > ${DEVICE_PATH}/command
50 if [ ${RET} -ne 0 ]; then
51 err "Failed to ${ACTION} internal LLDP agent for device ${DEVICE}"
55 log "${ACTION} internal LLDP agent for device ${DEVICE}"
59 function is_debugfs_mounted {
60 if grep -qs "${DEBUGFS_PATH}" /proc/mounts; then
66 function mount_debugfs {
67 mount -t debugfs none ${DEBUGFS_PATH}
70 function unmount_debugfs {
71 umount ${DEBUGFS_PATH}
74 function scan_devices {
76 local DEBUGFS_MOUNTED="false"
77 local DEVICES=${DEBUGFS_I40_DEVICES_PATH}/*
79 if is_debugfs_mounted; then
80 DEBUGFS_MOUNTED="true"
83 if [ ${DEBUGFS_MOUNTED} = "false" ]; then
86 if [ ${RET} -ne 0 ]; then
87 err "Failed to mount debugfs"
93 for DEVICE in $DEVICES; do
94 configure_device ${DEVICE} ${ACTION}
97 if [ ${DEBUGFS_MOUNTED} = "false" ]; then
100 if [ ${RET} -ne 0 ]; then
101 err "Failed to unmount debugfs"
104 log "Unmounted debugfs"
139 echo "Usage: $0 {start|stop|restart|status}"