Message ID | 1452183954-30413-1-git-send-email-bala.manoharan@linaro.org |
---|---|
State | Accepted |
Commit | c77eb3333fa86768068eac80ad9013cd84a2f273 |
Headers | show |
For this series: Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org> On Thu, Jan 7, 2016 at 10:25 AM, Balasubramanian Manoharan < bala.manoharan@linaro.org> wrote: > Implements Ethernet destination mac address verification > > Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> > --- > .../include/odp_classification_inlines.h | 25 > ++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > diff --git a/platform/linux-generic/include/odp_classification_inlines.h > b/platform/linux-generic/include/odp_classification_inlines.h > index e9739aa..a4c05d3 100644 > --- a/platform/linux-generic/include/odp_classification_inlines.h > +++ b/platform/linux-generic/include/odp_classification_inlines.h > @@ -153,11 +153,28 @@ static inline int verify_pmr_udp_sport(const uint8_t > *pkt_addr, > return 0; > } > > -static inline int verify_pmr_dmac(const uint8_t *pkt_addr ODP_UNUSED, > - odp_packet_hdr_t *pkt_hdr ODP_UNUSED, > - pmr_term_value_t *term_value ODP_UNUSED) > +static inline int verify_pmr_dmac(const uint8_t *pkt_addr, > + odp_packet_hdr_t *pkt_hdr, > + pmr_term_value_t *term_value) > { > - ODP_UNIMPLEMENTED(); > + uint64_t dmac = 0; > + uint64_t dmac_be = 0; > + const odph_ethhdr_t *eth; > + > + if (!pkt_hdr->input_flags.eth) > + return 0; > + > + eth = (const odph_ethhdr_t *)(pkt_addr + pkt_hdr->l2_offset); > + memcpy(&dmac_be, eth->dst.addr, ODPH_ETHADDR_LEN); > + dmac = odp_be_to_cpu_64(dmac_be); > + /* since we are converting a 48 bit ethernet address from BE to cpu > + format using odp_be_to_cpu_64() the last 16 bits needs to be right > + shifted */ > + if (dmac_be != dmac) > + dmac = dmac >> (64 - (ODPH_ETHADDR_LEN * 8)); > + > + if (term_value->val == (dmac & term_value->mask)) > + return 1; > return 0; > } > > -- > 1.9.1 > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp >
In my testing it breaks l2fwd test if I run 'make check' under root. Maxim. On 01/08/2016 00:55, Bill Fischofer wrote: > For this series: > > Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org > <mailto:bill.fischofer@linaro.org>> > > On Thu, Jan 7, 2016 at 10:25 AM, Balasubramanian Manoharan > <bala.manoharan@linaro.org <mailto:bala.manoharan@linaro.org>> wrote: > > Implements Ethernet destination mac address verification > > Signed-off-by: Balasubramanian Manoharan > <bala.manoharan@linaro.org <mailto:bala.manoharan@linaro.org>> > --- > .../include/odp_classification_inlines.h | 25 > ++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > diff --git > a/platform/linux-generic/include/odp_classification_inlines.h > b/platform/linux-generic/include/odp_classification_inlines.h > index e9739aa..a4c05d3 100644 > --- a/platform/linux-generic/include/odp_classification_inlines.h > +++ b/platform/linux-generic/include/odp_classification_inlines.h > @@ -153,11 +153,28 @@ static inline int verify_pmr_udp_sport(const > uint8_t *pkt_addr, > return 0; > } > > -static inline int verify_pmr_dmac(const uint8_t *pkt_addr ODP_UNUSED, > - odp_packet_hdr_t *pkt_hdr > ODP_UNUSED, > - pmr_term_value_t *term_value > ODP_UNUSED) > +static inline int verify_pmr_dmac(const uint8_t *pkt_addr, > + odp_packet_hdr_t *pkt_hdr, > + pmr_term_value_t *term_value) > { > - ODP_UNIMPLEMENTED(); > + uint64_t dmac = 0; > + uint64_t dmac_be = 0; > + const odph_ethhdr_t *eth; > + > + if (!pkt_hdr->input_flags.eth) > + return 0; > + > + eth = (const odph_ethhdr_t *)(pkt_addr + pkt_hdr->l2_offset); > + memcpy(&dmac_be, eth->dst.addr, ODPH_ETHADDR_LEN); > + dmac = odp_be_to_cpu_64(dmac_be); > + /* since we are converting a 48 bit ethernet address from > BE to cpu > + format using odp_be_to_cpu_64() the last 16 bits needs to > be right > + shifted */ > + if (dmac_be != dmac) > + dmac = dmac >> (64 - (ODPH_ETHADDR_LEN * 8)); > + > + if (term_value->val == (dmac & term_value->mask)) > + return 1; > return 0; > } > > -- > 1.9.1 > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> > https://lists.linaro.org/mailman/listinfo/lng-odp > > > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp
Merged! Maxim. Looks like my system was compiled with netmap support but no actual drivers. That was the reason for no packets in l2fwd. Maxim. On 01/13/2016 14:50, Maxim Uvarov wrote: > In my testing it breaks l2fwd test if I run 'make check' under root. > > Maxim. > > On 01/08/2016 00:55, Bill Fischofer wrote: >> For this series: >> >> Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org >> <mailto:bill.fischofer@linaro.org>> >> >> On Thu, Jan 7, 2016 at 10:25 AM, Balasubramanian Manoharan >> <bala.manoharan@linaro.org <mailto:bala.manoharan@linaro.org>> wrote: >> >> Implements Ethernet destination mac address verification >> >> Signed-off-by: Balasubramanian Manoharan >> <bala.manoharan@linaro.org <mailto:bala.manoharan@linaro.org>> >> --- >> .../include/odp_classification_inlines.h | 25 >> ++++++++++++++++++---- >> 1 file changed, 21 insertions(+), 4 deletions(-) >> >> diff --git >> a/platform/linux-generic/include/odp_classification_inlines.h >> b/platform/linux-generic/include/odp_classification_inlines.h >> index e9739aa..a4c05d3 100644 >> --- a/platform/linux-generic/include/odp_classification_inlines.h >> +++ b/platform/linux-generic/include/odp_classification_inlines.h >> @@ -153,11 +153,28 @@ static inline int verify_pmr_udp_sport(const >> uint8_t *pkt_addr, >> return 0; >> } >> >> -static inline int verify_pmr_dmac(const uint8_t *pkt_addr >> ODP_UNUSED, >> - odp_packet_hdr_t *pkt_hdr >> ODP_UNUSED, >> - pmr_term_value_t *term_value >> ODP_UNUSED) >> +static inline int verify_pmr_dmac(const uint8_t *pkt_addr, >> + odp_packet_hdr_t *pkt_hdr, >> + pmr_term_value_t *term_value) >> { >> - ODP_UNIMPLEMENTED(); >> + uint64_t dmac = 0; >> + uint64_t dmac_be = 0; >> + const odph_ethhdr_t *eth; >> + >> + if (!pkt_hdr->input_flags.eth) >> + return 0; >> + >> + eth = (const odph_ethhdr_t *)(pkt_addr + >> pkt_hdr->l2_offset); >> + memcpy(&dmac_be, eth->dst.addr, ODPH_ETHADDR_LEN); >> + dmac = odp_be_to_cpu_64(dmac_be); >> + /* since we are converting a 48 bit ethernet address from >> BE to cpu >> + format using odp_be_to_cpu_64() the last 16 bits needs to >> be right >> + shifted */ >> + if (dmac_be != dmac) >> + dmac = dmac >> (64 - (ODPH_ETHADDR_LEN * 8)); >> + >> + if (term_value->val == (dmac & term_value->mask)) >> + return 1; >> return 0; >> } >> >> -- >> 1.9.1 >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> >> https://lists.linaro.org/mailman/listinfo/lng-odp >> >> >> >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org >> https://lists.linaro.org/mailman/listinfo/lng-odp >
diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index e9739aa..a4c05d3 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -153,11 +153,28 @@ static inline int verify_pmr_udp_sport(const uint8_t *pkt_addr, return 0; } -static inline int verify_pmr_dmac(const uint8_t *pkt_addr ODP_UNUSED, - odp_packet_hdr_t *pkt_hdr ODP_UNUSED, - pmr_term_value_t *term_value ODP_UNUSED) +static inline int verify_pmr_dmac(const uint8_t *pkt_addr, + odp_packet_hdr_t *pkt_hdr, + pmr_term_value_t *term_value) { - ODP_UNIMPLEMENTED(); + uint64_t dmac = 0; + uint64_t dmac_be = 0; + const odph_ethhdr_t *eth; + + if (!pkt_hdr->input_flags.eth) + return 0; + + eth = (const odph_ethhdr_t *)(pkt_addr + pkt_hdr->l2_offset); + memcpy(&dmac_be, eth->dst.addr, ODPH_ETHADDR_LEN); + dmac = odp_be_to_cpu_64(dmac_be); + /* since we are converting a 48 bit ethernet address from BE to cpu + format using odp_be_to_cpu_64() the last 16 bits needs to be right + shifted */ + if (dmac_be != dmac) + dmac = dmac >> (64 - (ODPH_ETHADDR_LEN * 8)); + + if (term_value->val == (dmac & term_value->mask)) + return 1; return 0; }
Implements Ethernet destination mac address verification Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> --- .../include/odp_classification_inlines.h | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)