📄 ixethdbvlan.c
字号:
IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS); IX_ETH_DB_CHECK_VLAN_ID(vlanID); /* for safety isolate only the VLAN ID in the tag (the lower 12 bits) */ vlanID = vlanID & IX_ETH_DB_802_1Q_VLAN_MASK; /* check we're not asked to remove the default port VID */ if (vlanID == IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag)) { return IX_ETH_DB_NO_PERMISSION; } return ixEthDBPortVlanMembershipChange(portID, vlanID, ixEthDBPortInfo[portID].vlanMembership, REMOVE_VLAN);}/** * @brief adds or removes a VLAN range from a port's * VLAN membership table or TTI table * * @param portID ID of the port * @param vlanIDMin start of the VLAN range * @param vlanIDMax end of the VLAN range * @param table VLAN set to add or remove from * @param action ADD_VLAN or REMOVE_VLAN * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise * * @internal */IX_ETH_DB_PRIVATEIxEthDBStatus ixEthDBPortVlanMembershipRangeChange(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax, IxEthDBVlanSet table, UINT32 action){ UINT32 setOffsetMin, setOffsetMax; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS); IX_ETH_DB_CHECK_VLAN_ID(vlanIDMin); IX_ETH_DB_CHECK_VLAN_ID(vlanIDMax); /* for safety isolate only the VLAN ID in the tags (the lower 12 bits) */ vlanIDMin = vlanIDMin & IX_ETH_DB_802_1Q_VLAN_MASK; vlanIDMax = vlanIDMax & IX_ETH_DB_802_1Q_VLAN_MASK; /* is this a range? */ if (vlanIDMax < vlanIDMin) { return IX_ETH_DB_INVALID_VLAN; } /* check that we're not specifically asked to remove the default port VID */ if (action == REMOVE_VLAN && vlanIDMax == vlanIDMin && IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag) == vlanIDMin) { return IX_ETH_DB_NO_PERMISSION; } /* compute set offsets */ setOffsetMin = VLAN_SET_OFFSET(vlanIDMin); setOffsetMax = VLAN_SET_OFFSET(vlanIDMax); /* change VLAN range */ for (; vlanIDMin <= vlanIDMax ; vlanIDMin++) { /* change vlan in local membership table */ ixEthDBLocalVlanMembershipChange(vlanIDMin, table, action); } /* if the range is within one set (max 8 VLANs in one table byte) we can just update that entry in the NPE */ if (setOffsetMin == setOffsetMax) { /* send updated entry to NPE */ return ixEthDBVlanTableEntryUpdate(portID, setOffsetMin); } else { /* update a zone of the membership/transmit tag info table */ return ixEthDBVlanTableRangeUpdate(portID); }}/** * @brief adds a VLAN range to a port's VLAN membership table * * @param portID ID of the port * @param vlanIDMin start of the VLAN range * @param vlanIDMax end of the VLAN range * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortVlanMembershipRangeAdd(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); return ixEthDBPortVlanMembershipRangeChange(portID, vlanIDMin, vlanIDMax, ixEthDBPortInfo[portID].vlanMembership, ADD_VLAN);}/** * @brief removes a VLAN range from a port's VLAN membership table * * @param portID ID of the port * @param vlanIDMin start of the VLAN range * @param vlanIDMax end of the VLAN range * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortVlanMembershipRangeRemove(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); return ixEthDBPortVlanMembershipRangeChange(portID, vlanIDMin, vlanIDMax, ixEthDBPortInfo[portID].vlanMembership, REMOVE_VLAN);}/** * @brief sets a port's VLAN membership table or TTI table and * updates the NPE VLAN configuration * * @param portID ID of the port * @param portVlanTable port VLAN table to set * @param vlanSet new set contents * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise * * @internal */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBPortVlanTableSet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS); IX_ETH_DB_CHECK_REFERENCE(vlanSet); memcpy(portVlanTable, vlanSet, sizeof (IxEthDBVlanSet)); return ixEthDBVlanTableRangeUpdate(portID);}/** * @brief retireves a port's VLAN membership table or TTI table * * @param portID ID of the port * @param portVlanTable port VLAN table to retrieve * @param vlanSet address to * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise * * @internal */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBVlanTableGet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS); IX_ETH_DB_CHECK_REFERENCE(vlanSet); memcpy(vlanSet, portVlanTable, sizeof (IxEthDBVlanSet)); return IX_ETH_DB_SUCCESS;}/** * @brief sets a port's VLAN membership table * * @param portID ID of the port * @param vlanSet new VLAN membership table * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortVlanMembershipSet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet){ IxEthDBVlanId vlanID; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_REFERENCE(vlanSet); /* set the bit corresponding to the PVID just in case */ vlanID = IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag); vlanSet[VLAN_SET_OFFSET(vlanID)] |= 1 << VLAN_SET_MASK(vlanID); return ixEthDBPortVlanTableSet(portID, ixEthDBPortInfo[portID].vlanMembership, vlanSet);}/** * @brief retrieves a port's VLAN membership table * * @param portID ID of the port * @param vlanSet location to store the port's VLAN membership table * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortVlanMembershipGet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); return ixEthDBVlanTableGet(portID, ixEthDBPortInfo[portID].vlanMembership, vlanSet);}/** * @brief enables or disables Egress tagging for one VLAN ID * * @param portID ID of the port * @param vlanID VLAN ID to enable or disable Egress tagging on * @param enabled TRUE to enable and FALSE to disable tagging * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBEgressVlanEntryTaggingEnabledSet(IxEthDBPortId portID, IxEthDBVlanId vlanID, BOOL enabled){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_VLAN_ID(vlanID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS); return ixEthDBPortVlanMembershipChange(portID, vlanID, ixEthDBPortInfo[portID].transmitTaggingInfo, enabled? ADD_VLAN : REMOVE_VLAN);}/** * @brief retrieves the Egress tagging status for one VLAN ID * * @param portID ID of the port * @param vlanID VLAN ID to retrieve the tagging status for * @param enabled location to store the tagging status * (TRUE - tagging enabled, FALSE - tagging disabled) * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBEgressVlanEntryTaggingEnabledGet(IxEthDBPortId portID, IxEthDBVlanId vlanID, BOOL *enabled){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS); IX_ETH_DB_CHECK_REFERENCE(enabled); IX_ETH_DB_CHECK_VLAN_ID(vlanID); *enabled = ((ixEthDBPortInfo[portID].transmitTaggingInfo[VLAN_SET_OFFSET(vlanID)] & (1 << VLAN_SET_MASK(vlanID))) != 0); return IX_ETH_DB_SUCCESS;}/** * @brief enables or disables Egress VLAN tagging for a VLAN range * * @param portID ID of the port * @param vlanIDMin start of VLAN range * @param vlanIDMax end of VLAN range * @param enabled TRUE to enable or FALSE to disable VLAN tagging * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBEgressVlanRangeTaggingEnabledSet(IxEthDBPortId portID, IxEthDBVlanId vlanIDMin, IxEthDBVlanId vlanIDMax, BOOL enabled){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); return ixEthDBPortVlanMembershipRangeChange(portID, vlanIDMin, vlanIDMax, ixEthDBPortInfo[portID].transmitTaggingInfo, enabled? ADD_VLAN : REMOVE_VLAN);}/** * @brief sets the Egress VLAN tagging table (the Transmit Tagging * Information table) * * @param portID ID of the port * @param vlanSet new TTI table * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBEgressVlanTaggingEnabledSet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet){ IxEthDBVlanId vlanID; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_REFERENCE(vlanSet); /* set the PVID bit just in case */ vlanID = IX_ETH_DB_GET_VLAN_ID(ixEthDBPortInfo[portID].vlanTag); vlanSet[VLAN_SET_OFFSET(vlanID)] |= 1 << VLAN_SET_MASK(vlanID); return ixEthDBPortVlanTableSet(portID, ixEthDBPortInfo[portID].transmitTaggingInfo, vlanSet);}/** * @brief retrieves the Egress VLAN tagging table (the Transmit * Tagging Information table) * * @param portID ID of the port * @param vlanSet location to store the port's TTI table * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBEgressVlanTaggingEnabledGet(IxEthDBPortId portID, IxEthDBVlanSet vlanSet){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); return ixEthDBVlanTableGet(portID, ixEthDBPortInfo[portID].transmitTaggingInfo, vlanSet);}/** * @brief sends the NPE the updated frame filter and default * Ingress tagging * * @param portID ID of the port * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise * * @internal */IX_ETH_DB_PRIVATEIxEthDBStatus ixEthDBIngressVlanModeUpdate(IxEthDBPortId portID){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -