tap-as-a-service/bin/i40e_sysfs_command

29 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2018 AT&T Corporation
# All Rights Reserved.
#
# 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.
help_msg="Incorrect arguments supplied!! Aborting....\nUsage: 1. VLANs to VF mirroring: $0 <phy-device-name> <dest-vf-index> <'vlan_mirror'> <'add'|'rem'> <vlan_ranges_string>\nUsage: 2. VF to VF mirroring: $0 <phy-device-name> <src-vf-index> <'ingress_mirror'|'egress_mirror'> <'add'|'rem'> <dest-vf-index>"
(($#!=5)) && { echo -e ${help_msg} && exit 1; }
if [ -f /sys/class/net/${1}/device/sriov/${2}/${3} ]
then
echo ${4} ${5} > /sys/class/net/${1}/device/sriov/${2}/${3}
else
echo "Invalid sysfs path: /sys/class/net/${1}/device/sriov/${2}/${3}"
exit 1
fi