Open xfyan0408 opened 2 years ago
Hi linhil,
could you explain more in detail your issue, your message is not clear from my point of view. What I'm undestanding is that you have problem to install flow rules, via ONOS, on your P4 Pipeline. More in details:
P4Info constants
// Header field IDs
public static final PiMatchFieldId HDR_HDR_ETHERNET_DST_ADDR =
PiMatchFieldId.of("hdr.ethernet.dst_addr");
// Table IDs
public static final PiTableId SWITCH_INGRESS_FORWARD =
PiTableId.of("SwitchIngress.forward");
// Action IDs
public static final PiActionId SWITCH_INGRESS_HIT =
PiActionId.of("SwitchIngress.hit");
public static final PiActionId SWITCH_INGRESS_MISS =
PiActionId.of("SwitchIngress.miss");
// Action Param IDs
public static final PiActionParamId PORT = PiActionParamId.of("port");
the ONOS flow rule defined as follows:
private void setUpDevice(DeviceId deviceId) {
log.info("---------before Adding forwarding rules on {}... -----------", deviceId);
insertForwardingFlowRules(deviceId);
log.info("---------after Added forwarding rules on {}... -----------", deviceId);
}
private void insertForwardingFlowRules(DeviceId deviceId) {
final PiCriterion forwardingCriterion = PiCriterion.builder()
.matchExact(
P4InfoConstants.HDR_HDR_ETHERNET_DST_ADDR,
MacAddress.valueOf("11:11:11:11:11:11").toBytes())
.build();
final int port = 128;
final PiAction setForwardingAction = PiAction.builder()
.withId(P4InfoConstants.SWITCH_INGRESS_HIT)
.withParameter(new PiActionParam(P4InfoConstants.PORT,port))
.build();
final PiTableId tableId = P4InfoConstants.SWITCH_INGRESS_FORWARD;
final FlowRule rule = buildFlowRule(
deviceId, appId, tableId,
forwardingCriterion, setForwardingAction);
flowRuleService.applyFlowRules(rule);
}
public static FlowRule buildFlowRule(DeviceId switchId, ApplicationId appId,
PiTableId tableId, PiCriterion piCriterion,
PiTableAction piAction) {
return DefaultFlowRule.builder()
.forDevice(switchId)
.forTable(tableId)
.fromApp(appId)
.withPriority(DEFAULT_FLOW_RULE_PRIORITY)
.makePermanent()
.withSelector(DefaultTrafficSelector.builder()
.matchPi(piCriterion).build())
.withTreatment(DefaultTrafficTreatment.builder()
.piTableAction(piAction).build())
.build();
}
.
.
.
@Override // I registered a listener for device event
public void event(DeviceEvent event) {
final DeviceId deviceId = event.subject().id();
if (deviceService.isAvailable(deviceId)) {
executorService.execute(() -> {
log.info("{} event! deviceId={}", event.type(), deviceId);
setUpDevice(deviceId);
});
}
}
the log is as follows, but there are few infomation for flow rules It returns error
action hit() {
ig_tm_md.ucast_egress_port = 128;
}
The action hit ()
does not take in input a port value, so if you send:
inal PiAction setForwardingAction = PiAction.builder() .withId(P4InfoConstants.SWITCH_INGRESS_HIT) .withParameter(new PiActionParam(P4InfoConstants.PORT,port)) .build();
You sending a port value not required by the P4 actions, in other wolrd you should remove .withParameter(new PiActionParam(P4InfoConstants.PORT,port))
The action
hit ()
does not take in input a port value, so if you send:inal PiAction setForwardingAction = PiAction.builder() .withId(P4InfoConstants.SWITCH_INGRESS_HIT) .withParameter(new PiActionParam(P4InfoConstants.PORT,port)) .build();
You sending a port value not required by the P4 actions, in other wolrd you should remove.withParameter(new PiActionParam(P4InfoConstants.PORT,port))
I know what this mean, it logs no error when hit()
contains no input value, I tested it!
If I defined as
action hit(PortId_t port) {
ig_tm_md.ucast_egress_port = port;
}
it returns error as mentioned before :(, do you know how to fix it for hit(PortId_t port)
?
DefaultFlowRule.builder()
.forDevice(switchId)
.forTable(tableId)
.fromApp(appId)
.withPriority(DEFAULT_FLOW_RULE_PRIORITY)
.makePermanent()
.withSelector(DefaultTrafficSelector.builder()
.matchPi(piCriterion).build())
.withTreatment(DefaultTrafficTreatment.builder()
.piTableAction(piAction).build())
.build();
via the log.info(DefaultFlowRule.builder()...blabla.toString())
in this way you can see in the ONOS log how your flow rule is built.
- You have log errors related to initialize the pipeline so it seams that someting is wrong in the initilization of the pipeline via the controller, are you sure that P4 was compiled correctly?
- Did you try to define 128 as PortNumber object instad of int.
- you can print the
DefaultFlowRule.builder() .forDevice(switchId) .forTable(tableId) .fromApp(appId) .withPriority(DEFAULT_FLOW_RULE_PRIORITY) .makePermanent() .withSelector(DefaultTrafficSelector.builder() .matchPi(piCriterion).build()) .withTreatment(DefaultTrafficTreatment.builder() .piTableAction(piAction).build()) .build();
via the
log.info(DefaultFlowRule.builder()...blabla.toString())
in this way you can see in the ONOS log how your flow rule is built.
The flow rule is correct. I think is a problem related to the P4, more in details:
Thank you for your help, I tried adding entries in your code, and I determined that it is not the problem of the flow rules, but my pipeconfs settings, I have to take a look. In the way of installing entries by trick, it is found that using different bit-width parameters will cause errors in the installation of entries. The parameter's bitwidths in onos and p4 are not equal, I set as follows :
action hit(bit<8> port) {
ig_tm_md.ucast_egress_port = (bit<9>) port;
ingress_port_vlan_counter.count();
}
and set the ports to byte
Type
byte port_test = (byte) 128;
final TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.piTableAction(PiAction.builder()
.withId(P4InfoConstants.FABRIC_INGRESS_FILTERING_HIT)
.withParameter(new PiActionParam(P4InfoConstants.PORT, port_test))
.build())
.build();
it works fine!
yes, exactly
Thank you for your previous reply. I switched to my simple P4 program and just wanted to feed the stratum switch the table entry parameters on the controller side, May I ask what's the cause of this problem?
In addition, if I fix the action parameter to the P4 program will work fine
ONOS action parameter is as follows
P4 action parameter is as follows
but the onos's error log is
stratum log is
the chassis_config.pb.txt is