org.onosproject.net.pi.model.PiActionProfileId Java Examples
The following examples show how to use
org.onosproject.net.pi.model.PiActionProfileId.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utils.java From onos-p4-tutorial with Apache License 2.0 | 6 votes |
public static GroupDescription buildSelectGroup(DeviceId deviceId, String tableId, String actionProfileId, int groupId, Collection<PiAction> actions, ApplicationId appId) { final GroupKey groupKey = new PiGroupKey( PiTableId.of(tableId), PiActionProfileId.of(actionProfileId), groupId); final List<GroupBucket> buckets = actions.stream() .map(action -> DefaultTrafficTreatment.builder() .piTableAction(action).build()) .map(DefaultGroupBucket::createSelectGroupBucket) .collect(Collectors.toList()); return new DefaultGroupDescription( deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), groupKey, groupId, appId); }
Example #2
Source File: Utils.java From onos-p4-tutorial with Apache License 2.0 | 6 votes |
public static GroupDescription buildSelectGroup(DeviceId deviceId, String tableId, String actionProfileId, int groupId, Collection<PiAction> actions, ApplicationId appId) { final GroupKey groupKey = new PiGroupKey( PiTableId.of(tableId), PiActionProfileId.of(actionProfileId), groupId); final List<GroupBucket> buckets = actions.stream() .map(action -> DefaultTrafficTreatment.builder() .piTableAction(action).build()) .map(DefaultGroupBucket::createSelectGroupBucket) .collect(Collectors.toList()); return new DefaultGroupDescription( deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), groupKey, groupId, appId); }
Example #3
Source File: Utils.java From ngsdn-tutorial with Apache License 2.0 | 6 votes |
public static GroupDescription buildSelectGroup(DeviceId deviceId, String tableId, String actionProfileId, int groupId, Collection<PiAction> actions, ApplicationId appId) { final GroupKey groupKey = new PiGroupKey( PiTableId.of(tableId), PiActionProfileId.of(actionProfileId), groupId); final List<GroupBucket> buckets = actions.stream() .map(action -> DefaultTrafficTreatment.builder() .piTableAction(action).build()) .map(DefaultGroupBucket::createSelectGroupBucket) .collect(Collectors.toList()); return new DefaultGroupDescription( deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), groupKey, groupId, appId); }
Example #4
Source File: ReadRequestImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public P4RuntimeReadClient.ReadRequest actionProfileGroups(PiActionProfileId actionProfileId) { try { requestMsg.addEntities( P4RuntimeOuterClass.Entity.newBuilder() .setActionProfileGroup( P4RuntimeOuterClass.ActionProfileGroup.newBuilder() .setActionProfileId( p4ActionProfileId(actionProfileId)) .build()) .build()); } catch (InternalRequestException e) { log.warn("Unable to read groups for action profile '{}' from {}: {}", actionProfileId, client.deviceId(), e.getMessage()); } return this; }
Example #5
Source File: ReadRequestImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public P4RuntimeReadClient.ReadRequest actionProfileMembers(PiActionProfileId actionProfileId) { try { requestMsg.addEntities( P4RuntimeOuterClass.Entity.newBuilder() .setActionProfileMember( P4RuntimeOuterClass.ActionProfileMember.newBuilder() .setActionProfileId( p4ActionProfileId(actionProfileId)) .build()) .build()); } catch (InternalRequestException e) { log.warn("Unable to read members for action profile '{}' from {}: {}", actionProfileId, client.deviceId(), e.getMessage()); } return this; }
Example #6
Source File: ActionProfileGroupCodec.java From onos with Apache License 2.0 | 6 votes |
@Override public PiActionProfileGroup decode( ActionProfileGroup msg, Object ignored, PiPipeconf pipeconf, P4InfoBrowser browser) throws P4InfoBrowser.NotFoundException { final PiActionProfileGroup.Builder piGroupBuilder = PiActionProfileGroup.builder() .withActionProfileId(PiActionProfileId.of( browser.actionProfiles() .getById(msg.getActionProfileId()) .getPreamble().getName())) .withId(PiActionProfileGroupId.of(msg.getGroupId())) .withMaxSize(msg.getMaxSize()); msg.getMembersList().forEach(m -> { final int weight; if (m.getWeight() < 1) { log.warn("Decoding group with invalid weight '{}', will set to 1", m.getWeight()); weight = 1; } else { weight = m.getWeight(); } piGroupBuilder.addMember( PiActionProfileMemberId.of(m.getMemberId()), weight); }); return piGroupBuilder.build(); }
Example #7
Source File: ActionProfileMemberCodec.java From onos with Apache License 2.0 | 6 votes |
@Override public PiActionProfileMember decode( ActionProfileMember message, Object ignored, PiPipeconf pipeconf, P4InfoBrowser browser) throws P4InfoBrowser.NotFoundException, CodecException { final PiActionProfileId actionProfileId = PiActionProfileId.of( browser.actionProfiles() .getById(message.getActionProfileId()) .getPreamble() .getName()); return PiActionProfileMember.builder() .forActionProfile(actionProfileId) .withId(PiActionProfileMemberId.of(message.getMemberId())) .withAction(CODECS.action().decode( message.getAction(), null, pipeconf)) .build(); }
Example #8
Source File: P4ActionProfileModel.java From onos with Apache License 2.0 | 5 votes |
P4ActionProfileModel(PiActionProfileId id, ImmutableSet<PiTableId> tables, boolean hasSelector, long size, int maxGroupSize) { this.id = id; this.tables = tables; this.hasSelector = hasSelector; this.size = size; this.maxGroupSize = maxGroupSize; }
Example #9
Source File: PiActionProfileMember.java From onos with Apache License 2.0 | 5 votes |
private PiActionProfileMember(PiActionProfileId actionProfileId, PiActionProfileMemberId memberId, PiAction action) { this.actionProfileId = actionProfileId; this.memberId = memberId; this.action = action; }
Example #10
Source File: PiActionProfileGroup.java From onos with Apache License 2.0 | 5 votes |
private PiActionProfileGroup(PiActionProfileGroupId groupId, ImmutableMap<PiActionProfileMemberId, WeightedMember> members, PiActionProfileId actionProfileId, int maxSize) { this.groupId = groupId; this.members = members; this.actionProfileId = actionProfileId; this.maxSize = maxSize; }
Example #11
Source File: PiActionProfileMemberHandle.java From onos with Apache License 2.0 | 5 votes |
private PiActionProfileMemberHandle(DeviceId deviceId, PiActionProfileId actionProfileId, PiActionProfileMemberId memberId) { super(deviceId); this.actionProfileId = actionProfileId; this.memberId = memberId; }
Example #12
Source File: P4PipelineModel.java From onos with Apache License 2.0 | 5 votes |
P4PipelineModel( ImmutableMap<PiTableId, PiTableModel> tables, ImmutableMap<PiCounterId, PiCounterModel> counters, ImmutableMap<PiMeterId, PiMeterModel> meters, ImmutableMap<PiRegisterId, PiRegisterModel> registers, ImmutableMap<PiActionProfileId, PiActionProfileModel> actionProfiles, ImmutableMap<PiPacketOperationType, PiPacketOperationModel> packetOperations) { this.tables = tables; this.counters = counters; this.meters = meters; this.registers = registers; this.actionProfiles = actionProfiles; this.packetOperations = packetOperations; }
Example #13
Source File: P4InfoParser.java From onos with Apache License 2.0 | 5 votes |
private static Map<Integer, PiActionProfileModel> parseActionProfiles(P4Info p4info) throws P4InfoParserException { final Map<Integer, PiActionProfileModel> actProfileMap = Maps.newHashMap(); for (ActionProfile actProfileMsg : p4info.getActionProfilesList()) { final ImmutableSet.Builder<PiTableId> tableIdSetBuilder = ImmutableSet.builder(); for (int tableId : actProfileMsg.getTableIdsList()) { tableIdSetBuilder.add(PiTableId.of(getTableName(tableId, p4info))); } // TODO: we should copy all annotations to model classes for later // use in the PI framework. // This is a temporary workaround to the inability of p4c to // correctly interpret P4Runtime-defined max_group_size annotation: // https://s3-us-west-2.amazonaws.com/p4runtime/docs/master/ // P4Runtime-Spec.html#sec-p4info-action-profile final String maxSizeAnnString = findAnnotation( "max_group_size", actProfileMsg.getPreamble()); final int maxSizeAnn = maxSizeAnnString != null ? Integer.valueOf(maxSizeAnnString) : 0; final int maxGroupSize; if (actProfileMsg.getMaxGroupSize() == 0 && maxSizeAnn != 0) { log.warn("Found valid 'max_group_size' annotation for " + "ActionProfile {}, using that...", actProfileMsg.getPreamble().getName()); maxGroupSize = maxSizeAnn; } else { maxGroupSize = actProfileMsg.getMaxGroupSize(); } actProfileMap.put( actProfileMsg.getPreamble().getId(), new P4ActionProfileModel( PiActionProfileId.of(actProfileMsg.getPreamble().getName()), tableIdSetBuilder.build(), actProfileMsg.getWithSelector(), actProfileMsg.getSize(), maxGroupSize)); } return actProfileMap; }
Example #14
Source File: ActionProfileGroupCodec.java From onos with Apache License 2.0 | 5 votes |
private ActionProfileGroup.Builder keyMsgBuilder( PiActionProfileId actProfId, PiActionProfileGroupId groupId, P4InfoBrowser browser) throws P4InfoBrowser.NotFoundException { return ActionProfileGroup.newBuilder() .setGroupId(groupId.id()) .setActionProfileId(browser.actionProfiles() .getByName(actProfId.id()) .getPreamble().getId()); }
Example #15
Source File: ReadRequestImpl.java From onos with Apache License 2.0 | 5 votes |
private int p4ActionProfileId(PiActionProfileId piActionProfileId) throws InternalRequestException { try { return getBrowser().actionProfiles().getByName(piActionProfileId.id()) .getPreamble().getId(); } catch (P4InfoBrowser.NotFoundException e) { throw new InternalRequestException(e.getMessage()); } }
Example #16
Source File: ActionProfileMemberCodec.java From onos with Apache License 2.0 | 5 votes |
private P4RuntimeOuterClass.ActionProfileMember.Builder keyMsgBuilder( PiActionProfileId actProfId, PiActionProfileMemberId memberId, P4InfoBrowser browser) throws P4InfoBrowser.NotFoundException { return P4RuntimeOuterClass.ActionProfileMember.newBuilder() .setActionProfileId(browser.actionProfiles() .getByName(actProfId.id()) .getPreamble().getId()) .setMemberId(memberId.id()); }
Example #17
Source File: ReadRequestImpl.java From onos with Apache License 2.0 | 4 votes |
@Override public P4RuntimeReadClient.ReadRequest actionProfileMembers(Iterable<PiActionProfileId> actionProfileIds) { checkNotNull(actionProfileIds); actionProfileIds.forEach(this::actionProfileMembers); return this; }
Example #18
Source File: P4ActionProfileModel.java From onos with Apache License 2.0 | 4 votes |
@Override public PiActionProfileId id() { return id; }
Example #19
Source File: ReadRequestImpl.java From onos with Apache License 2.0 | 4 votes |
@Override public P4RuntimeReadClient.ReadRequest actionProfileGroups(Iterable<PiActionProfileId> actionProfileIds) { checkNotNull(actionProfileIds); actionProfileIds.forEach(this::actionProfileGroups); return this; }
Example #20
Source File: P4PipelineModel.java From onos with Apache License 2.0 | 4 votes |
@Override public Optional<PiActionProfileModel> actionProfiles(PiActionProfileId actionProfileId) { return Optional.ofNullable(actionProfiles.get(actionProfileId)); }
Example #21
Source File: PiActionProfileMemberHandle.java From onos with Apache License 2.0 | 3 votes |
/** * Creates a new handle for the given device ID, action profile ID, and * member ID. * * @param deviceId device ID * @param actionProfileId action profile ID * @param memberId member ID * @return action profile group member handle */ public static PiActionProfileMemberHandle of( DeviceId deviceId, PiActionProfileId actionProfileId, PiActionProfileMemberId memberId) { return new PiActionProfileMemberHandle( deviceId, actionProfileId, memberId); }
Example #22
Source File: PiActionProfileMember.java From onos with Apache License 2.0 | 2 votes |
/** * Sets the action profile identifier of this member. * * @param actionProfileId action profile identifier * @return this */ public Builder forActionProfile(PiActionProfileId actionProfileId) { this.actionProfileId = actionProfileId; return this; }
Example #23
Source File: PiActionProfileMember.java From onos with Apache License 2.0 | 2 votes |
/** * Returns the identifier of the action profile. * * @return action profile identifier */ public PiActionProfileId actionProfile() { return actionProfileId; }
Example #24
Source File: P4RuntimeReadClient.java From onos with Apache License 2.0 | 2 votes |
/** * Requests to read all action profile groups from the given action * profile. * * @param actionProfileId action profile ID * @return this */ ReadRequest actionProfileGroups(PiActionProfileId actionProfileId);
Example #25
Source File: PiActionProfileGroup.java From onos with Apache License 2.0 | 2 votes |
/** * Sets the ID of the action profile. * * @param piActionProfileId the ID of the action profile * @return this */ public Builder withActionProfileId(PiActionProfileId piActionProfileId) { this.actionProfileId = piActionProfileId; return this; }
Example #26
Source File: PiActionProfileGroup.java From onos with Apache License 2.0 | 2 votes |
/** * Returns the ID of the action profile where this group belong. * * @return action profile ID */ public PiActionProfileId actionProfile() { return actionProfileId; }
Example #27
Source File: P4RuntimeReadClient.java From onos with Apache License 2.0 | 2 votes |
/** * Requests to read all action profile groups from the given action * profiles. * * @param actionProfileIds action profile IDs * @return this */ ReadRequest actionProfileGroups(Iterable<PiActionProfileId> actionProfileIds);
Example #28
Source File: PiActionProfileMemberHandle.java From onos with Apache License 2.0 | 2 votes |
/** * Returns the action profile ID of this handle. * * @return action profile ID */ public PiActionProfileId actionProfileId() { return actionProfileId; }
Example #29
Source File: P4RuntimeReadClient.java From onos with Apache License 2.0 | 2 votes |
/** * Requests to read all action profile members from the given action * profile. * * @param actionProfileId action profile ID * @return this */ ReadRequest actionProfileMembers(PiActionProfileId actionProfileId);
Example #30
Source File: PiGroupKey.java From onos with Apache License 2.0 | 2 votes |
/** * Returns the action profile ID defined by this key. * * @return action profile ID */ public PiActionProfileId actionProfileId() { return piActionProfileId; }