aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
diff options
context:
space:
mode:
authorVipul Pandya <vipul@chelsio.com>2012-12-10 04:30:52 -0500
committerRoland Dreier <roland@purestorage.com>2012-12-19 12:28:19 -0500
commitf2b7e78dbc79e09fc1164b226adc03ed91a326cb (patch)
treef1ec25c2d5e09e89d6ef46e1e55676654cbfe357 /drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
parent5bd665f28db2b04a8d6fe277342479906fc60b62 (diff)
cxgb4: Add T4 filter support
The T4 architecture is capable of filtering ingress packets at line rate using the rule in TCAM. If packet hits a rule in the TCAM then it can be either dropped or passed to the receive queues based on a rule settings. This patch adds framework for managing filters and to use T4's filter capabilities. It constructs a Firmware Filter Work Request which writes the filter at a specified index to get the work done. It hosts shadow copy of ingress filter entry to check field size limitations and save memory in the case where the filter table is large. Signed-off-by: Vipul Pandya <vipul@chelsio.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/net/ethernet/chelsio/cxgb4/cxgb4.h')
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h131
1 files changed, 131 insertions, 0 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 378988b5709a..24ce797ddbbd 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -545,6 +545,129 @@ struct adapter {
545 spinlock_t stats_lock; 545 spinlock_t stats_lock;
546}; 546};
547 547
548/* Defined bit width of user definable filter tuples
549 */
550#define ETHTYPE_BITWIDTH 16
551#define FRAG_BITWIDTH 1
552#define MACIDX_BITWIDTH 9
553#define FCOE_BITWIDTH 1
554#define IPORT_BITWIDTH 3
555#define MATCHTYPE_BITWIDTH 3
556#define PROTO_BITWIDTH 8
557#define TOS_BITWIDTH 8
558#define PF_BITWIDTH 8
559#define VF_BITWIDTH 8
560#define IVLAN_BITWIDTH 16
561#define OVLAN_BITWIDTH 16
562
563/* Filter matching rules. These consist of a set of ingress packet field
564 * (value, mask) tuples. The associated ingress packet field matches the
565 * tuple when ((field & mask) == value). (Thus a wildcard "don't care" field
566 * rule can be constructed by specifying a tuple of (0, 0).) A filter rule
567 * matches an ingress packet when all of the individual individual field
568 * matching rules are true.
569 *
570 * Partial field masks are always valid, however, while it may be easy to
571 * understand their meanings for some fields (e.g. IP address to match a
572 * subnet), for others making sensible partial masks is less intuitive (e.g.
573 * MPS match type) ...
574 *
575 * Most of the following data structures are modeled on T4 capabilities.
576 * Drivers for earlier chips use the subsets which make sense for those chips.
577 * We really need to come up with a hardware-independent mechanism to
578 * represent hardware filter capabilities ...
579 */
580struct ch_filter_tuple {
581 /* Compressed header matching field rules. The TP_VLAN_PRI_MAP
582 * register selects which of these fields will participate in the
583 * filter match rules -- up to a maximum of 36 bits. Because
584 * TP_VLAN_PRI_MAP is a global register, all filters must use the same
585 * set of fields.
586 */
587 uint32_t ethtype:ETHTYPE_BITWIDTH; /* Ethernet type */
588 uint32_t frag:FRAG_BITWIDTH; /* IP fragmentation header */
589 uint32_t ivlan_vld:1; /* inner VLAN valid */
590 uint32_t ovlan_vld:1; /* outer VLAN valid */
591 uint32_t pfvf_vld:1; /* PF/VF valid */
592 uint32_t macidx:MACIDX_BITWIDTH; /* exact match MAC index */
593 uint32_t fcoe:FCOE_BITWIDTH; /* FCoE packet */
594 uint32_t iport:IPORT_BITWIDTH; /* ingress port */
595 uint32_t matchtype:MATCHTYPE_BITWIDTH; /* MPS match type */
596 uint32_t proto:PROTO_BITWIDTH; /* protocol type */
597 uint32_t tos:TOS_BITWIDTH; /* TOS/Traffic Type */
598 uint32_t pf:PF_BITWIDTH; /* PCI-E PF ID */
599 uint32_t vf:VF_BITWIDTH; /* PCI-E VF ID */
600 uint32_t ivlan:IVLAN_BITWIDTH; /* inner VLAN */
601 uint32_t ovlan:OVLAN_BITWIDTH; /* outer VLAN */
602
603 /* Uncompressed header matching field rules. These are always
604 * available for field rules.
605 */
606 uint8_t lip[16]; /* local IP address (IPv4 in [3:0]) */
607 uint8_t fip[16]; /* foreign IP address (IPv4 in [3:0]) */
608 uint16_t lport; /* local port */
609 uint16_t fport; /* foreign port */
610};
611
612/* A filter ioctl command.
613 */
614struct ch_filter_specification {
615 /* Administrative fields for filter.
616 */
617 uint32_t hitcnts:1; /* count filter hits in TCB */
618 uint32_t prio:1; /* filter has priority over active/server */
619
620 /* Fundamental filter typing. This is the one element of filter
621 * matching that doesn't exist as a (value, mask) tuple.
622 */
623 uint32_t type:1; /* 0 => IPv4, 1 => IPv6 */
624
625 /* Packet dispatch information. Ingress packets which match the
626 * filter rules will be dropped, passed to the host or switched back
627 * out as egress packets.
628 */
629 uint32_t action:2; /* drop, pass, switch */
630
631 uint32_t rpttid:1; /* report TID in RSS hash field */
632
633 uint32_t dirsteer:1; /* 0 => RSS, 1 => steer to iq */
634 uint32_t iq:10; /* ingress queue */
635
636 uint32_t maskhash:1; /* dirsteer=0: store RSS hash in TCB */
637 uint32_t dirsteerhash:1;/* dirsteer=1: 0 => TCB contains RSS hash */
638 /* 1 => TCB contains IQ ID */
639
640 /* Switch proxy/rewrite fields. An ingress packet which matches a
641 * filter with "switch" set will be looped back out as an egress
642 * packet -- potentially with some Ethernet header rewriting.
643 */
644 uint32_t eport:2; /* egress port to switch packet out */
645 uint32_t newdmac:1; /* rewrite destination MAC address */
646 uint32_t newsmac:1; /* rewrite source MAC address */
647 uint32_t newvlan:2; /* rewrite VLAN Tag */
648 uint8_t dmac[ETH_ALEN]; /* new destination MAC address */
649 uint8_t smac[ETH_ALEN]; /* new source MAC address */
650 uint16_t vlan; /* VLAN Tag to insert */
651
652 /* Filter rule value/mask pairs.
653 */
654 struct ch_filter_tuple val;
655 struct ch_filter_tuple mask;
656};
657
658enum {
659 FILTER_PASS = 0, /* default */
660 FILTER_DROP,
661 FILTER_SWITCH
662};
663
664enum {
665 VLAN_NOCHANGE = 0, /* default */
666 VLAN_REMOVE,
667 VLAN_INSERT,
668 VLAN_REWRITE
669};
670
548static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr) 671static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
549{ 672{
550 return readl(adap->regs + reg_addr); 673 return readl(adap->regs + reg_addr);
@@ -701,6 +824,12 @@ static inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,
701void t4_write_indirect(struct adapter *adap, unsigned int addr_reg, 824void t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
702 unsigned int data_reg, const u32 *vals, 825 unsigned int data_reg, const u32 *vals,
703 unsigned int nregs, unsigned int start_idx); 826 unsigned int nregs, unsigned int start_idx);
827void t4_read_indirect(struct adapter *adap, unsigned int addr_reg,
828 unsigned int data_reg, u32 *vals, unsigned int nregs,
829 unsigned int start_idx);
830
831struct fw_filter_wr;
832
704void t4_intr_enable(struct adapter *adapter); 833void t4_intr_enable(struct adapter *adapter);
705void t4_intr_disable(struct adapter *adapter); 834void t4_intr_disable(struct adapter *adapter);
706int t4_slow_intr_handler(struct adapter *adapter); 835int t4_slow_intr_handler(struct adapter *adapter);
@@ -737,6 +866,8 @@ void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
737void t4_load_mtus(struct adapter *adap, const unsigned short *mtus, 866void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
738 const unsigned short *alpha, const unsigned short *beta); 867 const unsigned short *alpha, const unsigned short *beta);
739 868
869void t4_mk_filtdelwr(unsigned int ftid, struct fw_filter_wr *wr, int qid);
870
740void t4_wol_magic_enable(struct adapter *adap, unsigned int port, 871void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
741 const u8 *addr); 872 const u8 *addr);
742int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map, 873int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,