Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is part of the Chelsio T4/T5/T6 Ethernet driver for Linux.
0003  *
0004  * Copyright (c) 2017 Chelsio Communications, Inc. All rights reserved.
0005  *
0006  * This software is available to you under a choice of one of two
0007  * licenses.  You may choose to be licensed under the terms of the GNU
0008  * General Public License (GPL) Version 2, available from the file
0009  * COPYING in the main directory of this source tree, or the
0010  * OpenIB.org BSD license below:
0011  *
0012  *     Redistribution and use in source and binary forms, with or
0013  *     without modification, are permitted provided that the following
0014  *     conditions are met:
0015  *
0016  *      - Redistributions of source code must retain the above
0017  *        copyright notice, this list of conditions and the following
0018  *        disclaimer.
0019  *
0020  *      - Redistributions in binary form must reproduce the above
0021  *        copyright notice, this list of conditions and the following
0022  *        disclaimer in the documentation and/or other materials
0023  *        provided with the distribution.
0024  *
0025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0026  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0027  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0028  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0029  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0030  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0031  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0032  * SOFTWARE.
0033  */
0034 
0035 #ifndef __CXGB4_TC_FLOWER_H
0036 #define __CXGB4_TC_FLOWER_H
0037 
0038 #include <net/pkt_cls.h>
0039 
0040 struct ch_tc_flower_stats {
0041     u64 prev_packet_count;
0042     u64 packet_count;
0043     u64 byte_count;
0044     u64 last_used;
0045 };
0046 
0047 struct ch_tc_flower_entry {
0048     struct ch_filter_specification fs;
0049     struct ch_tc_flower_stats stats;
0050     unsigned long tc_flower_cookie;
0051     struct rhash_head node;
0052     struct rcu_head rcu;
0053     spinlock_t lock; /* lock for stats */
0054     u32 filter_id;
0055 };
0056 
0057 enum {
0058     ETH_DMAC_31_0,  /* dmac bits 0.. 31 */
0059     ETH_DMAC_47_32, /* dmac bits 32..47 */
0060     ETH_SMAC_15_0,  /* smac bits 0.. 15 */
0061     ETH_SMAC_47_16, /* smac bits 16..47 */
0062 
0063     IP4_SRC,    /* 32-bit IPv4 src  */
0064     IP4_DST,    /* 32-bit IPv4 dst  */
0065 
0066     IP6_SRC_31_0,   /* src bits 0..  31 */
0067     IP6_SRC_63_32,  /* src bits 63.. 32 */
0068     IP6_SRC_95_64,  /* src bits 95.. 64 */
0069     IP6_SRC_127_96, /* src bits 127..96 */
0070 
0071     IP6_DST_31_0,   /* dst bits 0..  31 */
0072     IP6_DST_63_32,  /* dst bits 63.. 32 */
0073     IP6_DST_95_64,  /* dst bits 95.. 64 */
0074     IP6_DST_127_96, /* dst bits 127..96 */
0075 
0076     TCP_SPORT,  /* 16-bit TCP sport */
0077     TCP_DPORT,  /* 16-bit TCP dport */
0078 
0079     UDP_SPORT,  /* 16-bit UDP sport */
0080     UDP_DPORT,  /* 16-bit UDP dport */
0081 };
0082 
0083 struct ch_tc_pedit_fields {
0084     u8 field;
0085     u8 size;
0086     u32 offset;
0087 };
0088 
0089 #define PEDIT_FIELDS(type, field, size, fs_field, offset) \
0090     { type## field, size, \
0091         offsetof(struct ch_filter_specification, fs_field) + (offset) }
0092 
0093 #define PEDIT_ETH_DMAC_MASK     0xffff
0094 #define PEDIT_TCP_UDP_SPORT_MASK    0xffff
0095 #define PEDIT_ETH_DMAC_31_0     0x0
0096 #define PEDIT_ETH_DMAC_47_32_SMAC_15_0  0x4
0097 #define PEDIT_ETH_SMAC_47_16        0x8
0098 #define PEDIT_IP4_SRC           0xC
0099 #define PEDIT_IP4_DST           0x10
0100 #define PEDIT_IP6_SRC_31_0      0x8
0101 #define PEDIT_IP6_SRC_63_32     0xC
0102 #define PEDIT_IP6_SRC_95_64     0x10
0103 #define PEDIT_IP6_SRC_127_96        0x14
0104 #define PEDIT_IP6_DST_31_0      0x18
0105 #define PEDIT_IP6_DST_63_32     0x1C
0106 #define PEDIT_IP6_DST_95_64     0x20
0107 #define PEDIT_IP6_DST_127_96        0x24
0108 #define PEDIT_TCP_SPORT_DPORT       0x0
0109 #define PEDIT_UDP_SPORT_DPORT       0x0
0110 
0111 enum cxgb4_action_natmode_flags {
0112     CXGB4_ACTION_NATMODE_NONE = 0,
0113     CXGB4_ACTION_NATMODE_DIP = (1 << 0),
0114     CXGB4_ACTION_NATMODE_SIP = (1 << 1),
0115     CXGB4_ACTION_NATMODE_DPORT = (1 << 2),
0116     CXGB4_ACTION_NATMODE_SPORT = (1 << 3),
0117 };
0118 
0119 /* TC PEDIT action to NATMODE translation entry */
0120 struct cxgb4_natmode_config {
0121     enum chip_type chip;
0122     u8 flags;
0123     u8 natmode;
0124 };
0125 
0126 void cxgb4_process_flow_actions(struct net_device *in,
0127                 struct flow_action *actions,
0128                 struct ch_filter_specification *fs);
0129 int cxgb4_validate_flow_actions(struct net_device *dev,
0130                 struct flow_action *actions,
0131                 struct netlink_ext_ack *extack,
0132                 u8 matchall_filter);
0133 
0134 int cxgb4_tc_flower_replace(struct net_device *dev,
0135                 struct flow_cls_offload *cls);
0136 int cxgb4_tc_flower_destroy(struct net_device *dev,
0137                 struct flow_cls_offload *cls);
0138 int cxgb4_tc_flower_stats(struct net_device *dev,
0139               struct flow_cls_offload *cls);
0140 int cxgb4_flow_rule_replace(struct net_device *dev, struct flow_rule *rule,
0141                 u32 tc_prio, struct netlink_ext_ack *extack,
0142                 struct ch_filter_specification *fs, u32 *tid);
0143 int cxgb4_flow_rule_destroy(struct net_device *dev, u32 tc_prio,
0144                 struct ch_filter_specification *fs, int tid);
0145 
0146 int cxgb4_init_tc_flower(struct adapter *adap);
0147 void cxgb4_cleanup_tc_flower(struct adapter *adap);
0148 #endif /* __CXGB4_TC_FLOWER_H */