net: new checksum functions
[dpdk.git] / app / test-pmd / config.c
index 1dda5e4..71b34dd 100644 (file)
@@ -32,7 +32,7 @@
  */
 /*   BSD LICENSE
  *
- *   Copyright(c) 2013 6WIND.
+ *   Copyright 2013-2014 6WIND S.A.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -1683,7 +1683,7 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id)
                return;
        if (vlan_id_is_invalid(vlan_id))
                return;
-       ports[port_id].tx_ol_flags |= PKT_TX_VLAN_PKT;
+       ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_INSERT_VLAN;
        ports[port_id].tx_vlan_id = vlan_id;
 }
 
@@ -1692,7 +1692,7 @@ tx_vlan_reset(portid_t port_id)
 {
        if (port_id_is_invalid(port_id))
                return;
-       ports[port_id].tx_ol_flags &= ~PKT_TX_VLAN_PKT;
+       ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_INSERT_VLAN;
 }
 
 void
@@ -1756,17 +1756,6 @@ set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value)
        }
 }
 
-void
-tx_cksum_set(portid_t port_id, uint64_t ol_flags)
-{
-       uint64_t tx_ol_flags;
-       if (port_id_is_invalid(port_id))
-               return;
-       /* Clear last 8 bits and then set L3/4 checksum mask again */
-       tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0FFull);
-       ports[port_id].tx_ol_flags = ((ol_flags & 0xff) | tx_ol_flags);
-}
-
 void
 fdir_add_signature_filter(portid_t port_id, uint8_t queue_id,
                          struct rte_fdir_filter *fdir_filter)
@@ -2019,6 +2008,67 @@ fdir_set_masks(portid_t port_id, struct rte_fdir_masks *fdir_masks)
               "diag=%d\n", port_id, diag);
 }
 
+void
+fdir_set_flex_mask(portid_t port_id, struct rte_eth_fdir_flex_mask *cfg)
+{
+       struct rte_port *port;
+       struct rte_eth_fdir_flex_conf *flex_conf;
+       int i, idx = 0;
+
+       port = &ports[port_id];
+       flex_conf = &port->dev_conf.fdir_conf.flex_conf;
+       for (i = 0; i < RTE_ETH_FLOW_TYPE_MAX; i++) {
+               if (cfg->flow_type == flex_conf->flex_mask[i].flow_type) {
+                       idx = i;
+                       break;
+               }
+       }
+       if (i >= RTE_ETH_FLOW_TYPE_MAX) {
+               if (flex_conf->nb_flexmasks < RTE_DIM(flex_conf->flex_mask)) {
+                       idx = flex_conf->nb_flexmasks;
+                       flex_conf->nb_flexmasks++;
+               } else {
+                       printf("The flex mask table is full. Can not set flex"
+                               " mask for flow_type(%u).", cfg->flow_type);
+                       return;
+               }
+       }
+       (void)rte_memcpy(&flex_conf->flex_mask[idx],
+                        cfg,
+                        sizeof(struct rte_eth_fdir_flex_mask));
+}
+
+void
+fdir_set_flex_payload(portid_t port_id, struct rte_eth_flex_payload_cfg *cfg)
+{
+       struct rte_port *port;
+       struct rte_eth_fdir_flex_conf *flex_conf;
+       int i, idx = 0;
+
+       port = &ports[port_id];
+       flex_conf = &port->dev_conf.fdir_conf.flex_conf;
+       for (i = 0; i < RTE_ETH_PAYLOAD_MAX; i++) {
+               if (cfg->type == flex_conf->flex_set[i].type) {
+                       idx = i;
+                       break;
+               }
+       }
+       if (i >= RTE_ETH_PAYLOAD_MAX) {
+               if (flex_conf->nb_payloads < RTE_DIM(flex_conf->flex_set)) {
+                       idx = flex_conf->nb_payloads;
+                       flex_conf->nb_payloads++;
+               } else {
+                       printf("The flex payload table is full. Can not set"
+                               " flex payload for type(%u).", cfg->type);
+                       return;
+               }
+       }
+       (void)rte_memcpy(&flex_conf->flex_set[idx],
+                        cfg,
+                        sizeof(struct rte_eth_flex_payload_cfg));
+
+}
+
 void
 set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on)
 {