Skip to content

Commit b3d199b

Browse files
daniele-moroccascone
authored andcommitted
Small fixes and improvements on fabric.p4
- setting s_tag and c_tag for BNG as early as possible in the pipeline - ingress_port_vlan was matching on inner_vlan_tag but that field could be not present Change-Id: Id4d51159a314d45cec370471ed244a51fd74338b
1 parent cda74c8 commit b3d199b

File tree

17 files changed

+1591
-1845
lines changed

17 files changed

+1591
-1845
lines changed

pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/pipeliner/FilteringObjectiveTranslator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ private void ingressPortVlanRule(
161161
final boolean innerVlanValid = innerVlanCriterion != null
162162
&& !innerVlanCriterion.vlanId().equals(VlanId.NONE);
163163

164+
if (innerVlanValid && !capabilities.supportDoubleVlanTerm()) {
165+
throw new FabricPipelinerException(
166+
"Found 2 VLAN IDs, but the pipeline does not support double VLAN termination",
167+
ObjectiveError.UNSUPPORTED);
168+
}
169+
164170
final PiCriterion piCriterion = PiCriterion.builder()
165171
.matchExact(FabricConstants.HDR_VLAN_IS_VALID, outerVlanValid ? ONE : ZERO)
166172
.build();

pipelines/fabric/impl/src/main/resources/include/bng.p4

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,6 @@ control bng_ingress(
310310
bng_ingress_upstream() upstream;
311311
bng_ingress_downstream() downstream;
312312

313-
vlan_id_t s_tag = 0;
314-
vlan_id_t c_tag = 0;
315-
316313
// TABLE: t_line_map
317314
// Map s_tag and c_tag to a line ID to uniquely identify a subscriber
318315

@@ -322,8 +319,8 @@ control bng_ingress(
322319

323320
table t_line_map {
324321
key = {
325-
s_tag : exact @name("s_tag");
326-
c_tag : exact @name("c_tag");
322+
fmeta.bng.s_tag : exact @name("s_tag");
323+
fmeta.bng.c_tag : exact @name("c_tag");
327324
}
328325
actions = {
329326
set_line;
@@ -334,17 +331,7 @@ control bng_ingress(
334331
}
335332

336333
apply {
337-
if(hdr.pppoe.isValid()) {
338-
s_tag = hdr.vlan_tag.vlan_id;
339-
c_tag = hdr.inner_vlan_tag.vlan_id;
340-
} else {
341-
// We expect the packet to be downstream,
342-
// the tags are set by the next stage in the metadata.
343-
s_tag = fmeta.vlan_id;
344-
c_tag = fmeta.inner_vlan_id;
345-
}
346-
347-
// First map the double VLAN tags to a line ID
334+
// First map the double VLAN tags to a line ID
348335
// If table miss line ID will be 0.
349336
t_line_map.apply();
350337

pipelines/fabric/impl/src/main/resources/include/control/filtering.p4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ control Filtering (inout parsed_headers_t hdr,
4848
permit();
4949
}
5050

51-
// FIXME: remove the use of ternary match on valid inner VLAN.
51+
// FIXME: remove the use of ternary match on inner VLAN.
5252
// Use multi-table approach to remove ternary matching
5353
table ingress_port_vlan {
5454
key = {
5555
standard_metadata.ingress_port : exact @name("ig_port");
5656
hdr.vlan_tag.isValid() : exact @name("vlan_is_valid");
5757
hdr.vlan_tag.vlan_id : ternary @name("vlan_id");
58+
#ifdef WITH_DOUBLE_VLAN_TERMINATION
5859
hdr.inner_vlan_tag.vlan_id : ternary @name("inner_vlan_id");
60+
#endif // WITH_DOUBLE_VLAN_TERMINATION
5961
}
6062
actions = {
6163
deny();

pipelines/fabric/impl/src/main/resources/include/control/next.p4

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ control Next (inout parsed_headers_t hdr,
7676
set_vlan(outer_vlan_id);
7777
fabric_metadata.push_double_vlan = _TRUE;
7878
fabric_metadata.inner_vlan_id = inner_vlan_id;
79+
#ifdef WITH_BNG
80+
fabric_metadata.bng.s_tag = outer_vlan_id;
81+
fabric_metadata.bng.c_tag = inner_vlan_id;
82+
#endif // WITH_BNG
7983
}
8084
#endif // WITH_DOUBLE_VLAN_TERMINATION
8185

pipelines/fabric/impl/src/main/resources/include/header.p4

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,12 @@ const bng_type_t BNG_TYPE_UPSTREAM = 2w0x1;
162162
const bng_type_t BNG_TYPE_DOWNSTREAM = 2w0x2;;
163163

164164
struct bng_meta_t {
165-
bit<2> type; // upstream or downstream
166-
bit<32> line_id; // subscriber line
167-
bit<16> pppoe_session_id;
168-
bit<32> ds_meter_result; // for downstream metering
165+
bit<2> type; // upstream or downstream
166+
bit<32> line_id; // subscriber line
167+
bit<16> pppoe_session_id;
168+
bit<32> ds_meter_result; // for downstream metering
169+
vlan_id_t s_tag;
170+
vlan_id_t c_tag;
169171
}
170172
#endif // WITH_BNG
171173

pipelines/fabric/impl/src/main/resources/include/parser.p4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ parser FabricParser (packet_in packet,
5151

5252
state parse_vlan_tag {
5353
packet.extract(hdr.vlan_tag);
54+
#ifdef WITH_BNG
55+
fabric_metadata.bng.s_tag = hdr.vlan_tag.vlan_id;
56+
#endif // WITH_BNG
5457
transition select(packet.lookahead<bit<16>>()){
5558
#if defined(WITH_XCONNECT) || defined(WITH_DOUBLE_VLAN_TERMINATION)
5659
ETHERTYPE_VLAN: parse_inner_vlan_tag;
@@ -62,6 +65,9 @@ parser FabricParser (packet_in packet,
6265
#if defined(WITH_XCONNECT) || defined(WITH_DOUBLE_VLAN_TERMINATION)
6366
state parse_inner_vlan_tag {
6467
packet.extract(hdr.inner_vlan_tag);
68+
#ifdef WITH_BNG
69+
fabric_metadata.bng.c_tag = hdr.inner_vlan_tag.vlan_id;
70+
#endif // WITH_BNG
6571
transition parse_eth_type;
6672
}
6773
#endif // WITH_XCONNECT || WITH_DOUBLE_VLAN_TERMINATION

0 commit comments

Comments
 (0)