Message ID | 20230223112703.137872-6-cmi@nvidia.com |
---|---|
State | Changes Requested |
Headers | show |
Series | Add offload support for sFlow | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | fail | github build: failed |
ovsrobot/intel-ovs-compilation | success | test: success |
On 2/23/23 12:27, Chris Mi wrote: > Iterate each registered offload API. It's not a problem for today > since we only have one implementation. > > Signed-off-by: Chris Mi <cmi@nvidia.com> > Reviewed-by: Roi Dayan <roid@nvidia.com> > --- > lib/netdev-offload.c | 32 ++++++++++++++++++++++++++++++++ > lib/netdev-offload.h | 4 ++++ > 2 files changed, 36 insertions(+) > > diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c > index 4592262bd..b333a3b82 100644 > --- a/lib/netdev-offload.c > +++ b/lib/netdev-offload.c > @@ -256,6 +256,38 @@ meter_offload_del(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats) > return 0; > } > > +int > +netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf) Handler id. > +{ > + struct netdev_registered_flow_api *rfa; > + int ret; > + > + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { > + if (rfa->flow_api->sflow_recv) { > + ret = rfa->flow_api->sflow_recv(upcall, buf); > + if (ret) { > + VLOG_DBG_RL(&rl, "Failed to receive psample packet, error %d, " No 'sflow' or 'psample' in names or logs. > + "type: %s", ret, rfa->flow_api->type); strerror ? > + return ret; > + } > + } > + } > + > + return 0; > +} > + > +void > +netdev_offload_recv_wait(void) Same. > +{ > + struct netdev_registered_flow_api *rfa; > + > + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { > + if (rfa->flow_api->sflow_recv_wait) { > + rfa->flow_api->sflow_recv_wait(); > + } > + } > +} > + > int > netdev_flow_flush(struct netdev *netdev) > { > diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h > index edc843cd9..e332555ee 100644 > --- a/lib/netdev-offload.h > +++ b/lib/netdev-offload.h > @@ -33,6 +33,7 @@ extern "C" { > > struct dp_packet_batch; > struct dp_packet; > +struct dpif_upcall; > struct netdev_class; > struct netdev_rxq; > struct netdev_saved_flags; > @@ -162,6 +163,9 @@ void meter_offload_set(ofproto_meter_id, struct ofputil_meter_config *); > int meter_offload_get(ofproto_meter_id, struct ofputil_meter_stats *); > int meter_offload_del(ofproto_meter_id, struct ofputil_meter_stats *); > > +int netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf); > +void netdev_offload_recv_wait(void); > + > #ifdef __cplusplus > } > #endif
On 2/23/23 21:19, Ilya Maximets wrote: > On 2/23/23 12:27, Chris Mi wrote: >> Iterate each registered offload API. It's not a problem for today >> since we only have one implementation. >> >> Signed-off-by: Chris Mi <cmi@nvidia.com> >> Reviewed-by: Roi Dayan <roid@nvidia.com> >> --- >> lib/netdev-offload.c | 32 ++++++++++++++++++++++++++++++++ >> lib/netdev-offload.h | 4 ++++ >> 2 files changed, 36 insertions(+) >> >> diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c >> index 4592262bd..b333a3b82 100644 >> --- a/lib/netdev-offload.c >> +++ b/lib/netdev-offload.c >> @@ -256,6 +256,38 @@ meter_offload_del(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats) >> return 0; >> } >> >> +int >> +netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf) > > Handler id. > >> +{ >> + struct netdev_registered_flow_api *rfa; >> + int ret; >> + >> + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { >> + if (rfa->flow_api->sflow_recv) { >> + ret = rfa->flow_api->sflow_recv(upcall, buf); >> + if (ret) { >> + VLOG_DBG_RL(&rl, "Failed to receive psample packet, error %d, " > > No 'sflow' or 'psample' in names or logs. > >> + "type: %s", ret, rfa->flow_api->type); > > strerror ? > >> + return ret; Also, we should continue on error and return on success. Current core will call recv() for the next provider when the first one already returned a packet. >> + } >> + } >> + } >> + >> + return 0; >> +} >> + >> +void >> +netdev_offload_recv_wait(void) > > Same. > >> +{ >> + struct netdev_registered_flow_api *rfa; >> + >> + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { >> + if (rfa->flow_api->sflow_recv_wait) { >> + rfa->flow_api->sflow_recv_wait(); >> + } >> + } >> +} >> + >> int >> netdev_flow_flush(struct netdev *netdev) >> { >> diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h >> index edc843cd9..e332555ee 100644 >> --- a/lib/netdev-offload.h >> +++ b/lib/netdev-offload.h >> @@ -33,6 +33,7 @@ extern "C" { >> >> struct dp_packet_batch; >> struct dp_packet; >> +struct dpif_upcall; >> struct netdev_class; >> struct netdev_rxq; >> struct netdev_saved_flags; >> @@ -162,6 +163,9 @@ void meter_offload_set(ofproto_meter_id, struct ofputil_meter_config *); >> int meter_offload_get(ofproto_meter_id, struct ofputil_meter_stats *); >> int meter_offload_del(ofproto_meter_id, struct ofputil_meter_stats *); >> >> +int netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf); >> +void netdev_offload_recv_wait(void); >> + >> #ifdef __cplusplus >> } >> #endif >
On 2/24/2023 4:19 AM, Ilya Maximets wrote: > On 2/23/23 12:27, Chris Mi wrote: >> Iterate each registered offload API. It's not a problem for today >> since we only have one implementation. >> >> Signed-off-by: Chris Mi<cmi@nvidia.com> >> Reviewed-by: Roi Dayan<roid@nvidia.com> >> --- >> lib/netdev-offload.c | 32 ++++++++++++++++++++++++++++++++ >> lib/netdev-offload.h | 4 ++++ >> 2 files changed, 36 insertions(+) >> >> diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c >> index 4592262bd..b333a3b82 100644 >> --- a/lib/netdev-offload.c >> +++ b/lib/netdev-offload.c >> @@ -256,6 +256,38 @@ meter_offload_del(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats) >> return 0; >> } >> >> +int >> +netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf) > Handler id. Done. > >> +{ >> + struct netdev_registered_flow_api *rfa; >> + int ret; >> + >> + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { >> + if (rfa->flow_api->sflow_recv) { >> + ret = rfa->flow_api->sflow_recv(upcall, buf); >> + if (ret) { >> + VLOG_DBG_RL(&rl, "Failed to receive psample packet, error %d, " > No 'sflow' or 'psample' in names or logs. Done. > >> + "type: %s", ret, rfa->flow_api->type); > strerror ? Done. > >> + return ret; >> + } >> + } >> + } >> + >> + return 0; >> +} >> + >> +void >> +netdev_offload_recv_wait(void) > Same. Done. > >> +{ >> + struct netdev_registered_flow_api *rfa; >> + >> + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { >> + if (rfa->flow_api->sflow_recv_wait) { >> + rfa->flow_api->sflow_recv_wait(); >> + } >> + } >> +} >> + >> int >> netdev_flow_flush(struct netdev *netdev) >> { >> diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h >> index edc843cd9..e332555ee 100644 >> --- a/lib/netdev-offload.h >> +++ b/lib/netdev-offload.h >> @@ -33,6 +33,7 @@ extern "C" { >> >> struct dp_packet_batch; >> struct dp_packet; >> +struct dpif_upcall; >> struct netdev_class; >> struct netdev_rxq; >> struct netdev_saved_flags; >> @@ -162,6 +163,9 @@ void meter_offload_set(ofproto_meter_id, struct ofputil_meter_config *); >> int meter_offload_get(ofproto_meter_id, struct ofputil_meter_stats *); >> int meter_offload_del(ofproto_meter_id, struct ofputil_meter_stats *); >> >> +int netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf); >> +void netdev_offload_recv_wait(void); >> + >> #ifdef __cplusplus >> } >> #endif
diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 4592262bd..b333a3b82 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -256,6 +256,38 @@ meter_offload_del(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats) return 0; } +int +netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf) +{ + struct netdev_registered_flow_api *rfa; + int ret; + + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { + if (rfa->flow_api->sflow_recv) { + ret = rfa->flow_api->sflow_recv(upcall, buf); + if (ret) { + VLOG_DBG_RL(&rl, "Failed to receive psample packet, error %d, " + "type: %s", ret, rfa->flow_api->type); + return ret; + } + } + } + + return 0; +} + +void +netdev_offload_recv_wait(void) +{ + struct netdev_registered_flow_api *rfa; + + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { + if (rfa->flow_api->sflow_recv_wait) { + rfa->flow_api->sflow_recv_wait(); + } + } +} + int netdev_flow_flush(struct netdev *netdev) { diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index edc843cd9..e332555ee 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -33,6 +33,7 @@ extern "C" { struct dp_packet_batch; struct dp_packet; +struct dpif_upcall; struct netdev_class; struct netdev_rxq; struct netdev_saved_flags; @@ -162,6 +163,9 @@ void meter_offload_set(ofproto_meter_id, struct ofputil_meter_config *); int meter_offload_get(ofproto_meter_id, struct ofputil_meter_stats *); int meter_offload_del(ofproto_meter_id, struct ofputil_meter_stats *); +int netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf); +void netdev_offload_recv_wait(void); + #ifdef __cplusplus } #endif