forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: ixgbe: add minimal parser details for ixgbe
This adds an ixgbe data structure that is used to determine what headers:fields can be matched and in what order they are supported. For hardware devices this can be a bit tricky because typically only pre-programmed (firmware, ucode, rtl) parse graphs will be supported and we don't yet have an interface to change these from the OS. So its sort of a you get whatever your friendly vendor provides affair at the moment. In the future we can add the get routines and set routines to update this data structure. One interesting thing to note here is the data structure here identifies ethernet, ip, and tcp fields without having to hardcode them as enumerations or use other identifiers. Signed-off-by: John Fastabend <[email protected]> Acked-by: Jamal Hadi Salim <[email protected]> Signed-off-by: David S. Miller <[email protected]>
- Loading branch information
Showing
1 changed file
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/******************************************************************************* | ||
* | ||
* Intel 10 Gigabit PCI Express Linux drive | ||
* Copyright(c) 2013 - 2015 Intel Corporation. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* The full GNU General Public License is included in this distribution in | ||
* the file called "COPYING". | ||
* | ||
* Contact Information: | ||
* e1000-devel Mailing List <[email protected]> | ||
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
* | ||
******************************************************************************/ | ||
|
||
#ifndef _IXGBE_MODEL_H_ | ||
#define _IXGBE_MODEL_H_ | ||
|
||
#include "ixgbe.h" | ||
#include "ixgbe_type.h" | ||
|
||
struct ixgbe_mat_field { | ||
unsigned int off; | ||
unsigned int mask; | ||
int (*val)(struct ixgbe_fdir_filter *input, | ||
union ixgbe_atr_input *mask, | ||
__u32 val, __u32 m); | ||
unsigned int type; | ||
}; | ||
|
||
static inline int ixgbe_mat_prgm_sip(struct ixgbe_fdir_filter *input, | ||
union ixgbe_atr_input *mask, | ||
__u32 val, __u32 m) | ||
{ | ||
input->filter.formatted.src_ip[0] = val; | ||
mask->formatted.src_ip[0] = m; | ||
return 0; | ||
} | ||
|
||
static inline int ixgbe_mat_prgm_dip(struct ixgbe_fdir_filter *input, | ||
union ixgbe_atr_input *mask, | ||
__u32 val, __u32 m) | ||
{ | ||
input->filter.formatted.dst_ip[0] = val; | ||
mask->formatted.dst_ip[0] = m; | ||
return 0; | ||
} | ||
|
||
static struct ixgbe_mat_field ixgbe_ipv4_fields[] = { | ||
{ .off = 12, .mask = -1, .val = ixgbe_mat_prgm_sip, | ||
.type = IXGBE_ATR_FLOW_TYPE_IPV4}, | ||
{ .off = 16, .mask = -1, .val = ixgbe_mat_prgm_dip, | ||
.type = IXGBE_ATR_FLOW_TYPE_IPV4}, | ||
{ .val = NULL } /* terminal node */ | ||
}; | ||
|
||
static inline int ixgbe_mat_prgm_sport(struct ixgbe_fdir_filter *input, | ||
union ixgbe_atr_input *mask, | ||
__u32 val, __u32 m) | ||
{ | ||
input->filter.formatted.src_port = val & 0xffff; | ||
mask->formatted.src_port = m & 0xffff; | ||
return 0; | ||
}; | ||
|
||
static inline int ixgbe_mat_prgm_dport(struct ixgbe_fdir_filter *input, | ||
union ixgbe_atr_input *mask, | ||
__u32 val, __u32 m) | ||
{ | ||
input->filter.formatted.dst_port = val & 0xffff; | ||
mask->formatted.dst_port = m & 0xffff; | ||
return 0; | ||
}; | ||
|
||
static struct ixgbe_mat_field ixgbe_tcp_fields[] = { | ||
{.off = 0, .mask = 0xffff, .val = ixgbe_mat_prgm_sport, | ||
.type = IXGBE_ATR_FLOW_TYPE_TCPV4}, | ||
{.off = 2, .mask = 0xffff, .val = ixgbe_mat_prgm_dport, | ||
.type = IXGBE_ATR_FLOW_TYPE_TCPV4}, | ||
{ .val = NULL } /* terminal node */ | ||
}; | ||
|
||
struct ixgbe_nexthdr { | ||
/* offset, shift, and mask of position to next header */ | ||
unsigned int o; | ||
__u32 s; | ||
__u32 m; | ||
/* match criteria to make this jump*/ | ||
unsigned int off; | ||
__u32 val; | ||
__u32 mask; | ||
/* location of jump to make */ | ||
struct ixgbe_mat_field *jump; | ||
}; | ||
|
||
static struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = { | ||
{ .o = 0, .s = 6, .m = 0xf, | ||
.off = 8, .val = 0x600, .mask = 0xff00, .jump = ixgbe_tcp_fields}, | ||
{ .jump = NULL } /* terminal node */ | ||
}; | ||
#endif /* _IXGBE_MODEL_H_ */ |