[ovs-dev] [megaflow v3 1/2] datapath: Mega flow implementation

Andy Zhou azhou at nicira.com
Wed Jun 12 03:49:21 UTC 2013


Did not realize that the __CHECK_ENDIAN__ flags has to be passed by hand to
enable those checks.  This is what I use to verify the fix.  Any better way
to enable this check?

make C=2 CF="-D__CHECK_ENDIAN__"

The following incremental patch fixes those warnings.

Andy

diff --git a/datapath/flow.c b/datapath/flow.c
index 78ed921..5c8faac 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -138,37 +138,37 @@ static bool ovs_match_validate(const struct
sw_flow_match *match,
     /* Check key attributes. */
     if (match->key->eth.type == htons(ETH_P_ARP)) {
         key_expected |= 1ULL << OVS_KEY_ATTR_ARP;
-        if (match->mfm && (match->mfm->key.eth.type == ntohs(0xffff)))
+        if (match->mfm && (match->mfm->key.eth.type == htons(0xffff)))
             mask_allowed |= 1ULL << OVS_KEY_ATTR_ARP;
     }

     if (match->key->eth.type == htons(ETH_P_RARP)) {
         key_expected |= 1ULL << OVS_KEY_ATTR_ARP;
-        if (match->mfm && (match->mfm->key.eth.type == ntohs(0xffff)))
+        if (match->mfm && (match->mfm->key.eth.type == htons(0xffff)))
             mask_allowed |= 1ULL << OVS_KEY_ATTR_ARP;
     }

     if (match->key->eth.type == htons(ETH_P_IP)) {
         key_expected |= 1ULL << OVS_KEY_ATTR_IPV4;
-        if (match->mfm && (match->mfm->key.eth.type != ntohs(0xffff)))
+        if (match->mfm && (match->mfm->key.eth.type != htons(0xffff)))
             mask_allowed |= 1ULL << OVS_KEY_ATTR_IPV4;

         if (match->key->ip.frag != OVS_FRAG_TYPE_LATER) {
             if (match->key->ip.proto == IPPROTO_UDP) {
                 key_expected |= 1ULL << OVS_KEY_ATTR_UDP;
-                if (match->mfm && (match->mfm->key.ip.proto ==
ntohs(0xffff)))
+                if (match->mfm && (match->mfm->key.ip.proto == 0xff))
                     mask_allowed |= 1ULL << OVS_KEY_ATTR_UDP;
             }

             if (match->key->ip.proto == IPPROTO_TCP) {
                 key_expected |= 1ULL << OVS_KEY_ATTR_TCP;
-                if (match->mfm && (match->mfm->key.ip.proto ==
ntohs(0xffff)))
+                if (match->mfm && (match->mfm->key.ip.proto == 0xff))
                     mask_allowed |= 1ULL << OVS_KEY_ATTR_TCP;
             }

             if (match->key->ip.proto == IPPROTO_ICMP) {
                 key_expected |= 1ULL << OVS_KEY_ATTR_ICMP;
-                if (match->mfm && (match->mfm->key.ip.proto ==
ntohs(0xffff)))
+                if (match->mfm && (match->mfm->key.ip.proto == 0xff))
                     mask_allowed |= 1ULL << OVS_KEY_ATTR_ICMP;
             }
         }
@@ -176,37 +176,37 @@ static bool ovs_match_validate(const struct
sw_flow_match *match,

     if (match->key->eth.type == htons(ETH_P_IPV6)) {
         key_expected |= 1ULL << OVS_KEY_ATTR_IPV6;
-        if (match->mfm && (match->mfm->key.eth.type == ntohs(0xffff)))
+        if (match->mfm && (match->mfm->key.eth.type == htons(0xffff)))
             mask_allowed |= 1ULL << OVS_KEY_ATTR_IPV6;

         if (match->key->ip.frag != OVS_FRAG_TYPE_LATER) {
             if (match->key->ip.proto == IPPROTO_UDP) {
                 key_expected |= 1ULL << OVS_KEY_ATTR_UDP;
-                if (match->mfm && (match->mfm->key.ip.proto ==
ntohs(0xffff)))
+                if (match->mfm && (match->mfm->key.ip.proto == 0xff))
                     mask_allowed |= 1ULL << OVS_KEY_ATTR_UDP;
             }

             if (match->key->ip.proto == IPPROTO_TCP) {
                 key_expected |= 1ULL << OVS_KEY_ATTR_TCP;
-                if (match->mfm && (match->mfm->key.ip.proto ==
ntohs(0xffff)))
+                if (match->mfm && (match->mfm->key.ip.proto == 0xff))
                     mask_allowed |= 1ULL << OVS_KEY_ATTR_TCP;
             }

             if (match->key->ip.proto == IPPROTO_ICMPV6) {
                 key_expected |= 1ULL << OVS_KEY_ATTR_ICMPV6;
-                if (match->mfm && (match->mfm->key.ip.proto ==
ntohs(0xffff)))
+                if (match->mfm && (match->mfm->key.ip.proto == 0xff))
                     mask_allowed |= 1ULL << OVS_KEY_ATTR_ICMPV6;

                 if (match->key->ipv6.tp.src ==
                     htons(NDISC_NEIGHBOUR_SOLICITATION)) {
                     key_expected |= 1ULL << OVS_KEY_ATTR_ND;
-                    if (match->mfm && (match->mfm->key.ipv6.tp.src ==
ntohs(0xffff)))
+                    if (match->mfm && (match->mfm->key.ipv6.tp.src ==
htons(0xffff)))
                         mask_allowed |= 1ULL << OVS_KEY_ATTR_ND;
                 }

                 if (match->key->ipv6.tp.src ==
htons(NDISC_NEIGHBOUR_ADVERTISEMENT)) {
                     key_expected |= 1ULL << OVS_KEY_ATTR_ND;
-                    if (match->mfm && (match->mfm->key.ipv6.tp.src ==
ntohs(0xffff)))
+                    if (match->mfm && (match->mfm->key.ipv6.tp.src ==
htons(0xffff)))
                         mask_allowed |= 1ULL << OVS_KEY_ATTR_ND;
                 }
             }
@@ -1035,9 +1035,10 @@ void ovs_flow_tbl_insert(struct flow_table *table,
struct sw_flow *flow,
              const struct sw_flow_key *key, int key_len)
 {
     flow->unmasked_key = *key;
-    flow_key_mask(&flow->key, &flow->unmasked_key, flow->mfm);
-    flow->hash = ovs_flow_hash(&flow->key, flow->mfm->range.start,
-            flow->mfm->range.end);
+    flow_key_mask(&flow->key, &flow->unmasked_key,
ovsl_dereference(flow->mfm));
+    flow->hash = ovs_flow_hash(&flow->key,
+                               ovsl_dereference(flow->mfm)->range.start,
+                               ovsl_dereference(flow->mfm)->range.end);
     __tbl_insert(table, flow);
 }





On Tue, Jun 11, 2013 at 5:27 PM, Jesse Gross <jesse at nicira.com> wrote:

> On Tue, Jun 11, 2013 at 4:45 PM, Andy Zhou <azhou at nicira.com> wrote:
> > Add mega flow support in kernel datapath.
> >
> > Pravin has made significant contributions to this patch. Including
> > the mega flow id look up scheme, API clean ups, and bug fixes.
> >
> > Co-authored-by: Pravin B Shelar <pshelar at nicira.com>
> > Signed-off-by: Pravin B Shelar <pshelar at nicira.com>
> > Signed-off-by: Andy Zhou <azhou at nicira.com>
>
> There are a lot of new sparse errors, can you take a look?:
>
>   CHECK   /home/jgross/openvswitch/datapath/linux/flow.c
> /home/jgross/openvswitch/datapath/linux/flow.c:141:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:141:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:141:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:141:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:141:55: warning:
> restricted __be16 degrades to integer
> /home/jgross/openvswitch/datapath/linux/flow.c:147:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:147:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:147:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:147:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:147:55: warning:
> restricted __be16 degrades to integer
> /home/jgross/openvswitch/datapath/linux/flow.c:153:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:153:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:153:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:153:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:153:55: warning:
> restricted __be16 degrades to integer
> /home/jgross/openvswitch/datapath/linux/flow.c:159:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:159:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:159:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:159:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:165:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:165:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:165:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:165:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:171:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:171:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:171:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:171:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:179:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:179:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:179:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:179:64: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:179:55: warning:
> restricted __be16 degrades to integer
> /home/jgross/openvswitch/datapath/linux/flow.c:185:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:185:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:185:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:185:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:191:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:191:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:191:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:191:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:197:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:197:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:197:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:197:80: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:203:91: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:203:91: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:203:91: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:203:91: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:203:83: warning:
> restricted __be16 degrades to integer
> /home/jgross/openvswitch/datapath/linux/flow.c:209:91: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:209:91: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:209:91: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:209:91: warning: cast
> to restricted __be16
> /home/jgross/openvswitch/datapath/linux/flow.c:209:83: warning:
> restricted __be16 degrades to integer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20130611/00cc8ad2/attachment-0003.html>


More information about the dev mailing list