net/ipn3ke: support flow API

Add Intel FPGA Acceleration NIC IPN3KE Flow of PMD driver.

Signed-off-by: Rosen Xu <rosen.xu@intel.com>
Signed-off-by: Andy Pei <andy.pei@intel.com>
Signed-off-by: Dan Wei <dan.wei@intel.com>
This commit is contained in:
Rosen Xu 2019-04-16 11:17:43 +08:00 committed by Ferruh Yigit
parent c820468ac9
commit 6ad943ff49
8 changed files with 1492 additions and 2 deletions

View File

@ -35,5 +35,6 @@ LIBABIVER := 1
SRCS-$(CONFIG_RTE_LIBRTE_IPN3KE_PMD) += ipn3ke_ethdev.c
SRCS-$(CONFIG_RTE_LIBRTE_IPN3KE_PMD) += ipn3ke_representor.c
SRCS-$(CONFIG_RTE_LIBRTE_IPN3KE_PMD) += ipn3ke_tm.c
SRCS-$(CONFIG_RTE_LIBRTE_IPN3KE_PMD) += ipn3ke_flow.c
include $(RTE_SDK)/mk/rte.lib.mk

View File

@ -21,6 +21,7 @@
#include <ifpga_logs.h>
#include "ipn3ke_rawdev_api.h"
#include "ipn3ke_flow.h"
#include "ipn3ke_logs.h"
#include "ipn3ke_ethdev.h"
@ -266,6 +267,10 @@ ipn3ke_hw_init(struct rte_afu_device *afu_dev,
if (ret)
return ret;
hw->tm_hw_enable = 1;
ret = ipn3ke_flow_init(hw);
if (ret)
return ret;
hw->flow_hw_enable = 1;
}

View File

@ -291,6 +291,7 @@ struct ipn3ke_hw {
uint32_t acc_tm;
uint32_t acc_flow;
struct ipn3ke_flow_list flow_list;
uint32_t flow_max_entries;
uint32_t flow_num_entries;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,106 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2019 Intel Corporation
*/
#ifndef _IPN3KE_FLOW_H_
#define _IPN3KE_FLOW_H_
/**
* Expand the length to DWORD alignment with 'Unused' field.
*
* FLOW KEY:
* | Unused |Ruler id (id) | Key1 Key2 (data) |
* |--------+---------------+--------------------|
* | 17bits | 3 bits | Total 108 bits |
* MSB ---> LSB
*
* Note: And the MSb of key data is filled to 0 when it is less
* than 108 bit.
*/
#define IPN3KE_FLOW_KEY_UNUSED_BITS 17
#define IPN3KE_FLOW_KEY_ID_BITS 3
#define IPN3KE_FLOW_KEY_DATA_BITS 108
#define IPN3KE_FLOW_KEY_TOTAL_BITS \
(IPN3KE_FLOW_KEY_UNUSED_BITS + \
IPN3KE_FLOW_KEY_ID_BITS + \
IPN3KE_FLOW_KEY_DATA_BITS)
#define IPN3KE_FLOW_KEY_ID_OFFSET \
(IPN3KE_FLOW_KEY_UNUSED_BITS)
#define IPN3KE_FLOW_KEY_DATA_OFFSET \
(IPN3KE_FLOW_KEY_ID_OFFSET + IPN3KE_FLOW_KEY_ID_BITS)
/**
* Expand the length to DWORD alignment with 'Unused' field.
*
* FLOW RESULT:
* | Unused | enable (acl) | uid |
* |---------+--------------+--------------|
* | 15 bits | 1 bit | 16 bits |
* MSB ---> LSB
*/
#define IPN3KE_FLOW_RESULT_UNUSED_BITS 15
#define IPN3KE_FLOW_RESULT_ACL_BITS 1
#define IPN3KE_FLOW_RESULT_UID_BITS 16
#define IPN3KE_FLOW_RESULT_TOTAL_BITS \
(IPN3KE_FLOW_RESULT_UNUSED_BITS + \
IPN3KE_FLOW_RESULT_ACL_BITS + \
IPN3KE_FLOW_RESULT_UID_BITS)
#define IPN3KE_FLOW_RESULT_ACL_OFFSET \
(IPN3KE_FLOW_RESULT_UNUSED_BITS)
#define IPN3KE_FLOW_RESULT_UID_OFFSET \
(IPN3KE_FLOW_RESULT_ACL_OFFSET + IPN3KE_FLOW_RESULT_ACL_BITS)
#define IPN3KE_FLOW_RESULT_UID_MAX \
((1UL << IPN3KE_FLOW_RESULT_UID_BITS) - 1)
#ifndef BITS_PER_BYTE
#define BITS_PER_BYTE 8
#endif
#define BITS_TO_BYTES(bits) \
(((bits) + BITS_PER_BYTE - 1) / BITS_PER_BYTE)
struct ipn3ke_flow_rule {
uint8_t key[BITS_TO_BYTES(IPN3KE_FLOW_KEY_TOTAL_BITS)];
uint8_t result[BITS_TO_BYTES(IPN3KE_FLOW_RESULT_TOTAL_BITS)];
};
struct rte_flow {
TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
struct ipn3ke_flow_rule rule;
};
TAILQ_HEAD(ipn3ke_flow_list, rte_flow);
static inline uint16_t ipn3ke_swap16(uint16_t x)
{
return ((x & 0xff) << 8) | ((x >> 8) & 0xff);
}
static inline uint32_t ipn3ke_swap32(uint32_t x)
{
uint32_t high, low;
uint32_t high1, low1;
high = (x >> 16) & 0xffff;
low = x & 0xffff;
high1 = ipn3ke_swap16(low);
high1 = high1 << 16;
low1 = ipn3ke_swap16(high);
low1 = low1 & 0xffff;
return high1 | low1;
}
extern const struct rte_flow_ops ipn3ke_flow_ops;
int ipn3ke_flow_init(void *dev);
#endif /* _IPN3KE_FLOW_H_ */

View File

@ -21,6 +21,7 @@
#include <ifpga_logs.h>
#include "ipn3ke_rawdev_api.h"
#include "ipn3ke_flow.h"
#include "ipn3ke_logs.h"
#include "ipn3ke_ethdev.h"
@ -746,7 +747,7 @@ ipn3ke_afu_filter_ctrl(struct rte_eth_dev *ethdev,
case RTE_ETH_FILTER_GENERIC:
if (filter_op != RTE_ETH_FILTER_GET)
return -EINVAL;
*(const void **)arg = NULL;
*(const void **)arg = &ipn3ke_flow_ops;
break;
default:
IPN3KE_AFU_PMD_WARN("Filter type (%d) not supported",

View File

@ -23,6 +23,7 @@
#include <ifpga_logs.h>
#include "ipn3ke_rawdev_api.h"
#include "ipn3ke_flow.h"
#include "ipn3ke_logs.h"
#include "ipn3ke_ethdev.h"

View File

@ -12,5 +12,6 @@ allow_experimental_apis = true
sources += files('ipn3ke_ethdev.c',
'ipn3ke_representor.c',
'ipn3ke_tm.c')
'ipn3ke_tm.c',
'ipn3ke_flow.c')
deps += ['bus_ifpga', 'sched']