186bb752cSjklos /************************************************************************** 286bb752cSjklos 386bb752cSjklos Copyright (c) 2007, Chelsio Inc. 486bb752cSjklos All rights reserved. 586bb752cSjklos 686bb752cSjklos Redistribution and use in source and binary forms, with or without 786bb752cSjklos modification, are permitted provided that the following conditions are met: 886bb752cSjklos 986bb752cSjklos 1. Redistributions of source code must retain the above copyright notice, 1086bb752cSjklos this list of conditions and the following disclaimer. 1186bb752cSjklos 1286bb752cSjklos 2. Neither the name of the Chelsio Corporation nor the names of its 1386bb752cSjklos contributors may be used to endorse or promote products derived from 1486bb752cSjklos this software without specific prior written permission. 1586bb752cSjklos 1686bb752cSjklos THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1786bb752cSjklos AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1886bb752cSjklos IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1986bb752cSjklos ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2086bb752cSjklos LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2186bb752cSjklos CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2286bb752cSjklos SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2386bb752cSjklos INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2486bb752cSjklos CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2586bb752cSjklos ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2686bb752cSjklos POSSIBILITY OF SUCH DAMAGE. 2786bb752cSjklos 2886bb752cSjklos ***************************************************************************/ 2986bb752cSjklos #ifndef __CHIOCTL_H__ 3086bb752cSjklos #define __CHIOCTL_H__ 3186bb752cSjklos 32*74422c2fSdholland #include <sys/ioccom.h> 33*74422c2fSdholland 34*74422c2fSdholland 3586bb752cSjklos /* 3686bb752cSjklos * Ioctl commands specific to this driver. 3786bb752cSjklos */ 3886bb752cSjklos enum { 3986bb752cSjklos CH_SETREG = 0x40, 4086bb752cSjklos CH_GETREG, 4186bb752cSjklos CH_SETTPI, 4286bb752cSjklos CH_GETTPI, 4386bb752cSjklos CH_DEVUP, 4486bb752cSjklos CH_GETMTUTAB, 4586bb752cSjklos CH_SETMTUTAB, 4686bb752cSjklos CH_GETMTU, 4786bb752cSjklos CH_SET_PM, 4886bb752cSjklos CH_GET_PM, 4986bb752cSjklos CH_GET_TCAM, 5086bb752cSjklos CH_SET_TCAM, 5186bb752cSjklos CH_GET_TCB, 5286bb752cSjklos CH_READ_TCAM_WORD, 5386bb752cSjklos CH_GET_MEM, 5486bb752cSjklos CH_GET_SGE_CONTEXT, 5586bb752cSjklos CH_GET_SGE_DESC, 5686bb752cSjklos CH_LOAD_FW, 5786bb752cSjklos CH_GET_PROTO, 5886bb752cSjklos CH_SET_PROTO, 5986bb752cSjklos CH_SET_TRACE_FILTER, 6086bb752cSjklos CH_SET_QSET_PARAMS, 6186bb752cSjklos CH_GET_QSET_PARAMS, 6286bb752cSjklos CH_SET_QSET_NUM, 6386bb752cSjklos CH_GET_QSET_NUM, 6486bb752cSjklos CH_SET_PKTSCHED, 6586bb752cSjklos CH_IFCONF_GETREGS, 6686bb752cSjklos CH_GETMIIREGS, 6786bb752cSjklos CH_SETMIIREGS, 6886bb752cSjklos CH_SET_FILTER, 6986bb752cSjklos CH_SET_HW_SCHED, 7086bb752cSjklos CH_DEL_FILTER, 7186bb752cSjklos }; 7286bb752cSjklos 7386bb752cSjklos struct ch_reg { 7486bb752cSjklos uint32_t addr; 7586bb752cSjklos uint32_t val; 7686bb752cSjklos }; 7786bb752cSjklos 7886bb752cSjklos struct ch_cntxt { 7986bb752cSjklos uint32_t cntxt_type; 8086bb752cSjklos uint32_t cntxt_id; 8186bb752cSjklos uint32_t data[4]; 8286bb752cSjklos }; 8386bb752cSjklos 8486bb752cSjklos /* context types */ 8586bb752cSjklos enum { CNTXT_TYPE_EGRESS, CNTXT_TYPE_FL, CNTXT_TYPE_RSP, CNTXT_TYPE_CQ }; 8686bb752cSjklos 8786bb752cSjklos struct ch_desc { 8886bb752cSjklos uint32_t cmd; 8986bb752cSjklos uint32_t queue_num; 9086bb752cSjklos uint32_t idx; 9186bb752cSjklos uint32_t size; 9286bb752cSjklos uint8_t data[128]; 9386bb752cSjklos }; 9486bb752cSjklos 9586bb752cSjklos struct ch_mem_range { 9686bb752cSjklos uint32_t cmd; 9786bb752cSjklos uint32_t mem_id; 9886bb752cSjklos uint32_t addr; 9986bb752cSjklos uint32_t len; 10086bb752cSjklos uint32_t version; 10186bb752cSjklos uint8_t *buf; 10286bb752cSjklos }; 10386bb752cSjklos 10486bb752cSjklos struct ch_qset_params { 10586bb752cSjklos uint32_t qset_idx; 10686bb752cSjklos int32_t txq_size[3]; 10786bb752cSjklos int32_t rspq_size; 10886bb752cSjklos int32_t fl_size[2]; 10986bb752cSjklos int32_t intr_lat; 11086bb752cSjklos int32_t polling; 11186bb752cSjklos int32_t cong_thres; 11286bb752cSjklos int32_t vector; 11386bb752cSjklos int32_t qnum; 11486bb752cSjklos }; 11586bb752cSjklos 11686bb752cSjklos struct ch_pktsched_params { 11786bb752cSjklos uint32_t cmd; 11886bb752cSjklos uint8_t sched; 11986bb752cSjklos uint8_t idx; 12086bb752cSjklos uint8_t min; 12186bb752cSjklos uint8_t max; 12286bb752cSjklos uint8_t binding; 12386bb752cSjklos }; 12486bb752cSjklos 12586bb752cSjklos struct ch_hw_sched { 12686bb752cSjklos uint32_t cmd; 12786bb752cSjklos uint8_t sched; 12886bb752cSjklos int8_t mode; 12986bb752cSjklos int8_t channel; 13086bb752cSjklos int32_t kbps; /* rate in Kbps */ 13186bb752cSjklos int32_t class_ipg; /* tenths of nanoseconds */ 13286bb752cSjklos uint32_t flow_ipg; /* usec */ 13386bb752cSjklos }; 13486bb752cSjklos 13586bb752cSjklos struct ch_filter_tuple { 13686bb752cSjklos uint32_t sip; 13786bb752cSjklos uint32_t dip; 13886bb752cSjklos uint16_t sport; 13986bb752cSjklos uint16_t dport; 14086bb752cSjklos uint16_t vlan:12; 14186bb752cSjklos uint16_t vlan_prio:3; 14286bb752cSjklos }; 14386bb752cSjklos 14486bb752cSjklos struct ch_filter { 14586bb752cSjklos uint32_t cmd; 14686bb752cSjklos uint32_t filter_id; 14786bb752cSjklos struct ch_filter_tuple val; 14886bb752cSjklos struct ch_filter_tuple mask; 14986bb752cSjklos uint16_t mac_addr_idx; 15086bb752cSjklos uint8_t mac_hit:1; 15186bb752cSjklos uint8_t proto:2; 15286bb752cSjklos 15386bb752cSjklos uint8_t want_filter_id:1; /* report filter TID instead of RSS hash */ 15486bb752cSjklos uint8_t pass:1; /* whether to pass or drop packets */ 15586bb752cSjklos uint8_t rss:1; /* use RSS or specified qset */ 15686bb752cSjklos uint8_t qset; 15786bb752cSjklos }; 15886bb752cSjklos 15986bb752cSjklos #ifndef TCB_SIZE 16086bb752cSjklos # define TCB_SIZE 128 16186bb752cSjklos #endif 16286bb752cSjklos 16386bb752cSjklos /* TCB size in 32-bit words */ 16486bb752cSjklos #define TCB_WORDS (TCB_SIZE / 4) 16586bb752cSjklos 16686bb752cSjklos enum { MEM_CM, MEM_PMRX, MEM_PMTX }; /* ch_mem_range.mem_id values */ 16786bb752cSjklos 16886bb752cSjklos struct ch_mtus { 16986bb752cSjklos uint32_t cmd; 17086bb752cSjklos uint32_t nmtus; 17186bb752cSjklos uint16_t mtus[NMTUS]; 17286bb752cSjklos }; 17386bb752cSjklos 17486bb752cSjklos struct ch_pm { 17586bb752cSjklos uint32_t cmd; 17686bb752cSjklos uint32_t tx_pg_sz; 17786bb752cSjklos uint32_t tx_num_pg; 17886bb752cSjklos uint32_t rx_pg_sz; 17986bb752cSjklos uint32_t rx_num_pg; 18086bb752cSjklos uint32_t pm_total; 18186bb752cSjklos }; 18286bb752cSjklos 18386bb752cSjklos struct ch_tcam { 18486bb752cSjklos uint32_t cmd; 18586bb752cSjklos uint32_t tcam_size; 18686bb752cSjklos uint32_t nservers; 18786bb752cSjklos uint32_t nroutes; 18886bb752cSjklos uint32_t nfilters; 18986bb752cSjklos }; 19086bb752cSjklos 19186bb752cSjklos struct ch_tcb { 19286bb752cSjklos uint32_t cmd; 19386bb752cSjklos uint32_t tcb_index; 19486bb752cSjklos uint32_t tcb_data[TCB_WORDS]; 19586bb752cSjklos }; 19686bb752cSjklos 19786bb752cSjklos struct ch_tcam_word { 19886bb752cSjklos uint32_t cmd; 19986bb752cSjklos uint32_t addr; 20086bb752cSjklos uint32_t buf[3]; 20186bb752cSjklos }; 20286bb752cSjklos 20386bb752cSjklos struct ch_trace { 20486bb752cSjklos uint32_t cmd; 20586bb752cSjklos uint32_t sip; 20686bb752cSjklos uint32_t sip_mask; 20786bb752cSjklos uint32_t dip; 20886bb752cSjklos uint32_t dip_mask; 20986bb752cSjklos uint16_t sport; 21086bb752cSjklos uint16_t sport_mask; 21186bb752cSjklos uint16_t dport; 21286bb752cSjklos uint16_t dport_mask; 21386bb752cSjklos uint32_t vlan:12, 21486bb752cSjklos vlan_mask:12, 21586bb752cSjklos intf:4, 21686bb752cSjklos intf_mask:4; 21786bb752cSjklos uint8_t proto; 21886bb752cSjklos uint8_t proto_mask; 21986bb752cSjklos uint8_t invert_match:1, 22086bb752cSjklos config_tx:1, 22186bb752cSjklos config_rx:1, 22286bb752cSjklos trace_tx:1, 22386bb752cSjklos trace_rx:1; 22486bb752cSjklos }; 22586bb752cSjklos 22686bb752cSjklos #define REGDUMP_SIZE (4 * 1024) 22786bb752cSjklos 22886bb752cSjklos struct ifconf_regs { 22986bb752cSjklos uint32_t version; 23086bb752cSjklos uint32_t len; /* bytes */ 23186bb752cSjklos uint8_t *data; 23286bb752cSjklos }; 23386bb752cSjklos 23486bb752cSjklos struct mii_data { 23586bb752cSjklos uint32_t phy_id; 23686bb752cSjklos uint32_t reg_num; 23786bb752cSjklos uint32_t val_in; 23886bb752cSjklos uint32_t val_out; 23986bb752cSjklos }; 24086bb752cSjklos 24186bb752cSjklos #define CHELSIO_SETREG _IOW('f', CH_SETREG, struct ch_reg) 24286bb752cSjklos #define CHELSIO_GETREG _IOWR('f', CH_GETREG, struct ch_reg) 24386bb752cSjklos #define CHELSIO_READ_TCAM_WORD _IOR('f', CH_READ_TCAM_WORD, struct ch_tcam) 24486bb752cSjklos #define CHELSIO_GET_MEM _IOWR('f', CH_GET_MEM, struct ch_mem_range) 24586bb752cSjklos #define CHELSIO_GET_SGE_CONTEXT _IOWR('f', CH_GET_SGE_CONTEXT, struct ch_cntxt) 24686bb752cSjklos #define CHELSIO_GET_SGE_DESC _IOWR('f', CH_GET_SGE_DESC, struct ch_desc) 24786bb752cSjklos #define CHELSIO_GET_QSET_PARAMS _IOWR('f', CH_GET_QSET_PARAMS, struct ch_qset_params) 24886bb752cSjklos #define CHELSIO_SET_QSET_PARAMS _IOW('f', CH_SET_QSET_PARAMS, struct ch_qset_params) 24986bb752cSjklos #define CHELSIO_GET_QSET_NUM _IOWR('f', CH_GET_QSET_NUM, struct ch_reg) 25086bb752cSjklos #define CHELSIO_SET_QSET_NUM _IOW('f', CH_SET_QSET_NUM, struct ch_reg) 25186bb752cSjklos #define CHELSIO_GETMTUTAB _IOR('f', CH_GET_QSET_NUM, struct ch_mtus) 25286bb752cSjklos #define CHELSIO_SETMTUTAB _IOW('f', CH_SET_QSET_NUM, struct ch_mtus) 25386bb752cSjklos 25486bb752cSjklos 25586bb752cSjklos #define CHELSIO_SET_TRACE_FILTER _IOW('f', CH_SET_TRACE_FILTER, struct ch_trace) 25686bb752cSjklos #define CHELSIO_SET_PKTSCHED _IOW('f', CH_SET_PKTSCHED, struct ch_pktsched_params) 25786bb752cSjklos #define CHELSIO_IFCONF_GETREGS _IOWR('f', CH_IFCONF_GETREGS, struct ifconf_regs) 25886bb752cSjklos #define SIOCGMIIREG _IOWR('f', CH_GETMIIREGS, struct mii_data) 25986bb752cSjklos #define SIOCSMIIREG _IOWR('f', CH_SETMIIREGS, struct mii_data) 26086bb752cSjklos #define CHELSIO_SET_HW_SCHED _IOWR('f', CH_SET_HW_SCHED, struct ch_hw_sched) 26186bb752cSjklos #define CHELSIO_SET_FILTER _IOW('f', CH_SET_FILTER, struct ch_filter) 26286bb752cSjklos #define CHELSIO_DEL_FILTER _IOW('f', CH_DEL_FILTER, struct ch_filter) 26386bb752cSjklos #define CHELSIO_DEVUP _IO('f', CH_DEVUP) 26486bb752cSjklos #endif 265