Skip to content

Commit 72461d3

Browse files
authored
32-way fanout for ecmp (#110)
ecmp support for IPv6
1 parent 3e6ec79 commit 72461d3

File tree

17 files changed

+3452
-2939
lines changed

17 files changed

+3452
-2939
lines changed

asic/src/softnpu/table.rs

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ pub struct Table {
2525
// soft-npu table names
2626
const ROUTER_V4_RT: &str = "ingress.router.v4_route.rtr";
2727
const ROUTER_V4_IDX: &str = "ingress.router.v4_idx.rtr";
28-
const ROUTER_V6: &str = "ingress.router.v6.rtr";
28+
const ROUTER_V6_RT: &str = "ingress.router.v6_route.rtr";
29+
const ROUTER_V6_IDX: &str = "ingress.router.v6_idx.rtr";
2930
const LOCAL_V6: &str = "ingress.local.local_v6";
3031
const LOCAL_V4: &str = "ingress.local.local_v4";
3132
const NAT_V4: &str = "ingress.nat.nat_v4";
@@ -44,7 +45,10 @@ const ROUTER4_LOOKUP_RT: &str =
4445
"pipe.Ingress.l3_router.Router4.lookup_idx.route";
4546
const ROUTER4_LOOKUP_IDX: &str =
4647
"pipe.Ingress.l3_router.Router4.lookup_idx.lookup";
47-
const ROUTER6_LOOKUP: &str = "pipe.Ingress.l3_router.Router6.lookup.tbl";
48+
const ROUTER6_LOOKUP_RT: &str =
49+
"pipe.Ingress.l3_router.Router6.lookup_idx.route";
50+
const ROUTER6_LOOKUP_IDX: &str =
51+
"pipe.Ingress.l3_router.Router6.lookup_idx.lookup";
4852
const NDP: &str = "pipe.Ingress.l3_router.Router6.Ndp.tbl";
4953
const ARP: &str = "pipe.Ingress.l3_router.Router4.Arp.tbl";
5054
const DPD_MAC_REWRITE: &str = "pipe.Ingress.mac_rewrite.mac_rewrite";
@@ -65,8 +69,11 @@ impl TableOps<Handle> for Table {
6569
ROUTER4_LOOKUP_IDX => {
6670
(Some(ROUTER_V4_IDX.into()), Some(ROUTER4_LOOKUP_IDX.into()))
6771
}
68-
ROUTER6_LOOKUP => {
69-
(Some(ROUTER_V6.into()), Some(ROUTER6_LOOKUP.into()))
72+
ROUTER6_LOOKUP_RT => {
73+
(Some(ROUTER_V6_RT.into()), Some(ROUTER6_LOOKUP_RT.into()))
74+
}
75+
ROUTER6_LOOKUP_IDX => {
76+
(Some(ROUTER_V6_IDX.into()), Some(ROUTER6_LOOKUP_IDX.into()))
7077
}
7178
SWITCH_ADDR4 => (Some(LOCAL_V4.into()), Some(SWITCH_ADDR4.into())),
7279
SWITCH_ADDR6 => (Some(LOCAL_V6.into()), Some(SWITCH_ADDR6.into())),
@@ -225,20 +232,51 @@ impl TableOps<Handle> for Table {
225232
}
226233
("forward_vlan", params)
227234
}
228-
(ROUTER6_LOOKUP, "forward") => {
235+
(ROUTER6_LOOKUP_IDX, "index") => {
229236
let mut params = Vec::new();
230237
for arg in action_data.args.iter() {
231238
match &arg.value {
232-
ValueTypes::U64(v) => match arg.name.as_str() {
233-
"port" => {
234-
params.extend_from_slice(
235-
&(*v as u16).to_le_bytes(),
236-
);
239+
ValueTypes::U64(v) => {
240+
// 16 bit index
241+
// 8 bit slot count
242+
match arg.name.as_str() {
243+
"idx" => {
244+
let v = *v as u16;
245+
params.extend_from_slice(&v.to_le_bytes());
246+
}
247+
"slots" => {
248+
let v = *v as u8;
249+
params.extend_from_slice(&v.to_le_bytes());
250+
}
251+
x => {
252+
error!(hdl.log, "unexpected parameter: {dpd_table}::index {x}")
253+
}
237254
}
238-
x => {
239-
error!(hdl.log, "unexpected parameter: {dpd_table}::forward {x}")
255+
}
256+
ValueTypes::Ptr(v) => {
257+
params.extend_from_slice(v.as_slice());
258+
}
259+
}
260+
}
261+
("index", params)
262+
}
263+
(ROUTER6_LOOKUP_RT, "forward") => {
264+
let mut params = Vec::new();
265+
for arg in action_data.args.iter() {
266+
match &arg.value {
267+
ValueTypes::U64(v) => {
268+
// 16 bit port
269+
match arg.name.as_str() {
270+
"port" => {
271+
params.extend_from_slice(
272+
&(*v as u16).to_le_bytes(),
273+
);
274+
}
275+
x => {
276+
error!(hdl.log, "unexpected parameter: {dpd_table}::forward {x}")
277+
}
240278
}
241-
},
279+
}
242280
ValueTypes::Ptr(v) => {
243281
let mut buf = v.clone();
244282
buf.reverse();
@@ -248,25 +286,29 @@ impl TableOps<Handle> for Table {
248286
}
249287
("forward", params)
250288
}
251-
(ROUTER6_LOOKUP, "forward_vlan") => {
289+
(ROUTER6_LOOKUP_RT, "forward_vlan") => {
252290
let mut params = Vec::new();
253291
for arg in action_data.args.iter() {
254292
match &arg.value {
255-
ValueTypes::U64(v) => match arg.name.as_str() {
256-
"port" => {
257-
params.extend_from_slice(
258-
&(*v as u16).to_le_bytes(),
259-
);
260-
}
261-
"vlan_id" => {
262-
params.extend_from_slice(
263-
&(*v as u16).to_le_bytes(),
264-
);
265-
}
266-
x => {
267-
error!(hdl.log, "unexpected parameter: {dpd_table}::forward_vlan {x}")
293+
ValueTypes::U64(v) => {
294+
// 16 bit port
295+
// 12 bit vlan
296+
match arg.name.as_str() {
297+
"vlan_id" => {
298+
params.extend_from_slice(
299+
&(*v as u16).to_le_bytes(),
300+
);
301+
}
302+
"port" => {
303+
params.extend_from_slice(
304+
&(*v as u16).to_le_bytes(),
305+
);
306+
}
307+
x => {
308+
error!(hdl.log, "unexpected parameter: {dpd_table}::forward_vlan {x}")
309+
}
268310
}
269-
},
311+
}
270312
ValueTypes::Ptr(v) => {
271313
let mut buf = v.clone();
272314
buf.reverse();

dpd-client/src/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ impl Client {
7171
}
7272
}
7373

74-
impl From<&types::Ipv4Route> for types::RouteTarget {
75-
fn from(route: &types::Ipv4Route) -> types::RouteTarget {
76-
types::RouteTarget::V4(route.clone())
77-
}
78-
}
79-
80-
impl From<&types::Ipv6Route> for types::RouteTarget {
81-
fn from(route: &types::Ipv6Route) -> types::RouteTarget {
82-
types::RouteTarget::V6(route.clone())
83-
}
84-
}
85-
8674
impl std::fmt::Display for types::LinkState {
8775
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8876
match self {

dpd-client/tests/integration_tests/common.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::time::Duration;
1313
use std::{fmt, thread};
1414

1515
use anyhow::anyhow;
16-
use oxnet::IpNet;
1716
use oxnet::Ipv4Net;
1817
use oxnet::Ipv6Net;
1918
use slog::Drain;
@@ -1089,15 +1088,15 @@ async fn set_route_ipv6_common(
10891088
let cidr = subnet.parse::<Ipv6Net>()?;
10901089
let tgt_ip: Ipv6Addr = gw.parse()?;
10911090

1092-
let route = types::RouteSet {
1093-
cidr: IpNet::V6(cidr),
1094-
target: types::RouteTarget::V6(types::Ipv6Route {
1091+
let route = types::Ipv6RouteUpdate {
1092+
cidr,
1093+
target: types::Ipv6Route {
10951094
port_id: port_id.clone(),
10961095
link_id: link_id.clone(),
10971096
tgt_ip,
10981097
tag: switch.client.inner().tag.clone(),
10991098
vlan_id,
1100-
}),
1099+
},
11011100
replace: false,
11021101
};
11031102
switch
@@ -1195,15 +1194,15 @@ async fn set_route_ipv4_common(
11951194
let cidr = subnet.parse::<Ipv4Net>()?;
11961195
let tgt_ip: Ipv4Addr = gw.parse()?;
11971196
let (port_id, link_id) = switch.link_id(phys_port).unwrap();
1198-
let route = types::RouteSet {
1199-
cidr: IpNet::V4(cidr),
1200-
target: types::RouteTarget::V4(types::Ipv4Route {
1197+
let route = types::Ipv4RouteUpdate {
1198+
cidr,
1199+
target: types::Ipv4Route {
12011200
port_id: port_id.clone(),
12021201
link_id: link_id.clone(),
12031202
tgt_ip,
12041203
tag: switch.client.inner().tag.clone(),
12051204
vlan_id,
1206-
}),
1205+
},
12071206
replace: false,
12081207
};
12091208
switch

dpd-client/tests/integration_tests/nat.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,15 @@ async fn test_nat_ingress(switch: &Switch, test: &NatTest) -> TestResult {
335335
.await
336336
.unwrap();
337337
let cidr = Ipv6Net::new(test.gimlet_ip.parse().unwrap(), 64).unwrap();
338-
let route = types::RouteSet {
339-
cidr: cidr.into(),
340-
target: types::RouteTarget::V6(types::Ipv6Route {
338+
let route = types::Ipv6RouteUpdate {
339+
cidr,
340+
target: types::Ipv6Route {
341341
tag: switch.client.inner().tag.clone(),
342342
port_id,
343343
link_id,
344344
tgt_ip: test.gimlet_ip.parse().unwrap(),
345345
vlan_id: None,
346-
}),
346+
},
347347
replace: false,
348348
};
349349
switch.client.route_ipv6_set(&route).await.unwrap();

0 commit comments

Comments
 (0)