stratum / fabric-tna

The SD-Fabric data plane
https://docs.sd-fabric.org/
31 stars 15 forks source link

Errors:Unable to get the front port handle for dev : 0 : dev_port : 128 : Invalid arguments (3) #527

Open xfyan0408 opened 2 years ago

xfyan0408 commented 2 years ago

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 image

ONOS action parameter is as follows image

P4 action parameter is as follows image

but the onos's error log is image

stratum log is image

the chassis_config.pb.txt is

description: "Default Chassis Config for Netberg Aurora 710"
chassis {
  platform: PLT_GENERIC_BAREFOOT_TOFINO
  name: "Netberg Aurora 710"
}
nodes {
  id: 1
  slot: 1
  index: 1
}
singleton_ports {
  id: 1
  name: "1/0"
  slot: 1
  port: 1
  speed_bps: 40000000000
  config_params {
    admin_state: ADMIN_STATE_ENABLED
  }
  node: 1
}
Dscano commented 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:

xfyan0408 commented 2 years ago
  1. I use a simpler logic, referring to the form of the previous ONOS app flow rule installation, to register the device event to the app when the device connection is detected.There is no error when specifying the fixed action parameter in pipeline, so I think my P4InfoConstants setting is correct,

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 image It returns error image

  1. From the onos cli, flowrule state is Pending add, but if I fix the parameter, the state is ADDED, I think it's the PortId_t port causes the problem
   action hit() {
       ig_tm_md.ucast_egress_port = 128;
   }
  1. The port displayed as follows, I set PortId_t port as 128 image
Dscano commented 2 years ago

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))

xfyan0408 commented 2 years ago

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)?

Dscano commented 2 years ago
xfyan0408 commented 2 years ago
  • 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.

  1. The P4 is compiled correctly.
  2. I tried 64bit( Type long) and change to rich Type PortNumber. it returns the same issue, so I think it's probably because I miss some component for pipeline, but I did it successfully in the older version of onos<->stratum-switch, I just do not know why.
  3. The flow rule is as follows image
Dscano commented 2 years ago

The flow rule is correct. I think is a problem related to the P4, more in details:

xfyan0408 commented 2 years ago

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! image

Dscano commented 2 years ago

yes, exactly