Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xfyan0408 opened this issue Jul 27, 2022 · 9 comments

Comments

@xfyan0408
Copy link

xfyan0408 commented Jul 27, 2022

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
Copy link

Dscano commented Jul 27, 2022

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:

  • Are you using the action in the right table? more in details when you define the flow rule in ONOS you use an action supported by the table? Could you show to us the flow rules that you sent to the controller and the logs?
  • Which is the state of the flow rule in the device(Pendig add,added, etc)? you can see it in the onos GUI?
  • Which are the ports displayed on the switch in the controller view? Is present the port1 28? More in details the controller does not utilize the data plane numbering of the port, e.g., port 1/0 n the datplane is port 1 in the controller view.

@xfyan0408
Copy link
Author

xfyan0408 commented Jul 27, 2022

  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
Copy link

Dscano commented Jul 27, 2022

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
Copy link
Author

xfyan0408 commented Jul 27, 2022

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
Copy link

Dscano commented Jul 27, 2022

  • 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 long or PortNumber instead 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.

@xfyan0408
Copy link
Author

  • 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
Copy link

Dscano commented Jul 27, 2022

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

  • If the flow rules remains in state pending add means that you have sent is not consistent with the P4 declaration, from the point of view of the action/table.
  • due to the fact that you have error in the configuration of the pipelines, (you should see them periodically), I think that the flow rule that you send is correct but the pipeline is not installed or cannot be read by onos. This means that perhaps you may have sde version issue ( the sde in stratum is different from the sde of p4 compiler). You should try to install the pipeline manually in the switch via CLI or via P4Runtime client ( you shoud find a P$ runtime client here in the documentation https://github.com/stratum/fabric-tna#quick-steps) in order to undestand what is going on with your pipeline.

@xfyan0408
Copy link
Author

xfyan0408 commented Jul 27, 2022

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
Copy link

Dscano commented Jul 27, 2022

yes, exactly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants