Fixed double VLAN tagging override, implemented auto negotiation attribute
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2021-11-13 02:20:23 +01:00
parent 704df5b09d
commit 1be4ae25cc
4 changed files with 45 additions and 13 deletions

View file

@ -11,8 +11,8 @@ platform:
# Extra configuration entries (or whole file) follow here in order
entries:
# Required to have working VLAN tagging (802.1Q)
- ["api.port.allowFtagVlanTagging", "bool", "true"]
# Required to have working double VLAN tagging on PCIe ports
#- ["api.port.allowFtagVlanTagging", "bool", "true"]
#- ["api.platform.config.debug", "text", "CONFIG,MOD_STATE,MOD_LED,MOD_INTR,MOD_TYPE,PLAT_LOG"]
#- ["api.platform.lib.config.debug", "text", "I2C_RW,I2C_MUX,PORT_LED"]
@ -62,12 +62,12 @@ switch:
# Frames received by the switch with this destination MAC address will
# be automatically trapped to the CPU.
cpu_mac: 0x000000000000
8021x: true
bpdu: true
lacp: true
garp: true
#8021x: true
#bpdu: true
#lacp: true
#garp: true
# This trap is only valid for routed frames.
mtu_violation: true
#mtu_violation: true
# Broadcast flooding control. Values: forward, discard, forward_without_cpu (default), per_port
@ -80,6 +80,8 @@ switch:
# Flood all unicast frames for which the destination address is unknown on lookup.
# Note that the CPU will only receive unknown unicast frames on VLANs for which the CPU port is a member.
# For FM10000 devices, this attribute must be set to ''forward'' to ensure that the VLAN information retrieved from a packet received from a PEP port is properly forwarded in the FTAG of the egress packet going to the CPU port.
# If the ''port.unicast.flooding'' port attribute is used instead to forward unknown unicast packets to the CPU port, the VLAN information will not be preserved when such packets are forwarded to the CPU port.
# Unicast flooding control. Values: forward, discard, forward_without_cpu (default), per_port
unicast_flooding: forward
@ -97,6 +99,9 @@ vlans:
# When this attribute is disabled, ingressing traffic will only be switched at layer 2.
# Default false
routable: false
#TODO: trap_igmp + FM_PORT_PARSER
-
id: 2
attributes:
@ -235,7 +240,7 @@ ports:
vlans:
-
id: 1
# Tag egressing frames or not with ISL tag format, or VLAN other tagging mode defined, default false
# Tag egressing frames or not with ISL tag format, or VLAN other tagging mode defined, default false. PCIe forced to false
tag: false
# Values: disabled, listening, learning, forwarding, blocking
stp: forwarding
@ -269,6 +274,8 @@ ports:
# E.g., if the non-vlan tagged netdev interface (of PCIE) on the host has MTU 15342,
# then the corresponding Max Frame Size is 15342 + 14 (L2 header) + 4 (FCS) = 15360.
max_frame_size: 9036
# none (default), sgmii, clause37, clause73
#autonegotiation: clause73
-
# CPU port definitions

View file

@ -424,6 +424,14 @@ static std::unordered_map<std::string, fm_int> LAG_MODE = {
{"dynamic", FM_MODE_DYNAMIC},
};
static std::unordered_map<std::string, fm_int> AUTONEG_MAP = {
{"none", FM_PORT_AUTONEG_NONE},
{"sgmii", FM_PORT_AUTONEG_SGMII},
{"clause37", FM_PORT_AUTONEG_CLAUSE_37},
{"clause73", FM_PORT_AUTONEG_CLAUSE_73},
};
fm_int getMapState(const std::string& k, const std::unordered_map<std::string, fm_int>& m){
assert(m.find(k) != m.end());
return m.at(k);
@ -532,7 +540,7 @@ bool FM10K::FM10K::initialize(const ryml::Tree& tree) const {
}
std::cout << "Add port " << logicalPort << " to vlan " << vid << std::endl;
ies.fmAddVlanPort(vid, logicalPort, getYAMLBool(portVlan["tag"], true));
ies.fmAddVlanPort(vid, logicalPort, !isPCIePort && getYAMLBool(portVlan["tag"], true));
ies.fmSetVlanPortState(vid, logicalPort, getMapState(getYAMLString(portVlan["stp"], "forwarding"), STP_STATE_MAP));
}
}
@ -549,6 +557,8 @@ bool FM10K::FM10K::initialize(const ryml::Tree& tree) const {
ies.fmSetPortAttribute(logicalPort, FM_PORT_DEF_SWPRI, getYAMLUnsignedInteger(attr, 0));
}else if(key == "routable"){
ies.fmSetPortAttribute(logicalPort, FM_PORT_ROUTABLE, getYAMLBool(attr, isSpecialPort));
}else if(key == "autonegotiation" && isEplPort){
ies.fmSetPortAttribute(logicalPort, FM_PORT_AUTONEG, getMapState(getYAMLString(attr, "none"), AUTONEG_MAP));
}else if (key == "tagging" && attr.is_map()){
for(auto attr2 : attr){
std::string key2;

View file

@ -3,6 +3,7 @@
#include <unordered_map>
#include <sys/param.h>
#include <fstream>
#include <iostream>
#include "IES_SDK.h"
@ -121,9 +122,17 @@ void FM10K::IES::eventHandler(int event, int sw, void *ptr) {
}
break;
case FM_EVENT_PKT_RECV:
printf("packet received\n");
case FM_EVENT_PLATFORM:
if(ptr){
getInstance().handlePlatformEvent(sw, *static_cast<fm_eventPlatform*>(ptr));
}
break;
case FM_EVENT_PKT_RECV:
std::cout << "packet received" << std::endl;
break;
default:
std::cout << "Got event " << fmEventTypeToText(event) << std::endl;
}
}
@ -136,14 +145,14 @@ FM10K::IES &FM10K::IES::getInstance() {
void FM10K::IES::handleSwitchInsertedEvent(int sw) {
printf("Switch #%d inserted!\n", sw);
std::cout << "Switch #" << sw << " inserted!" << std::endl;
if (sw == IES_Static::sw){
fmReleaseSemaphore(&IES_Static::semaphore);
}
}
void FM10K::IES::handlePortEvent(int sw, _fm_eventPort& portEvent) {
printf("port event: port %d is %s\n", portEvent.port, (portEvent.linkStatus ? "up" : "down"));
std::cout << "port event: port " << portEvent.port << " is " << (portEvent.linkStatus ? "up" : "down") << std::endl;
}
bool FM10K::IES::replaceConfigEntry(const std::string &key, FM10K::IES::TlvType type, const std::string &value) {
@ -445,6 +454,10 @@ int FM10K::IES::fmGetSwitch() const {
return IES_Static::sw;
}
void FM10K::IES::handlePlatformEvent(int sw, _fm_eventPlatform &event) {
std::cout << event.type;
}
FM10K::IES::IES() = default;
IESException::IESException(int status) : m_msg(fmErrorMsg(status)) {

View file

@ -8,6 +8,7 @@
#include <functional>
struct _fm_eventPort;
struct _fm_eventPlatform;
struct _fm_switchInfo;
@ -99,6 +100,7 @@ namespace FM10K {
void handleSwitchInsertedEvent(int sw);
void handlePortEvent(int sw, struct _fm_eventPort&);
void handlePlatformEvent(int sw, struct _fm_eventPlatform&);
static void eventHandler(int event, int sw, void *ptr);
};