0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _IBMVETH_H
0015 #define _IBMVETH_H
0016
0017
0018 #define IbmVethMcastReceptionModifyBit 0x80000UL
0019 #define IbmVethMcastReceptionEnableBit 0x20000UL
0020 #define IbmVethMcastFilterModifyBit 0x40000UL
0021 #define IbmVethMcastFilterEnableBit 0x10000UL
0022
0023 #define IbmVethMcastEnableRecv (IbmVethMcastReceptionModifyBit | IbmVethMcastReceptionEnableBit)
0024 #define IbmVethMcastDisableRecv (IbmVethMcastReceptionModifyBit)
0025 #define IbmVethMcastEnableFiltering (IbmVethMcastFilterModifyBit | IbmVethMcastFilterEnableBit)
0026 #define IbmVethMcastDisableFiltering (IbmVethMcastFilterModifyBit)
0027 #define IbmVethMcastAddFilter 0x1UL
0028 #define IbmVethMcastRemoveFilter 0x2UL
0029 #define IbmVethMcastClearFilterTable 0x3UL
0030
0031 #define IBMVETH_ILLAN_LRG_SR_ENABLED 0x0000000000010000UL
0032 #define IBMVETH_ILLAN_LRG_SND_SUPPORT 0x0000000000008000UL
0033 #define IBMVETH_ILLAN_PADDED_PKT_CSUM 0x0000000000002000UL
0034 #define IBMVETH_ILLAN_TRUNK_PRI_MASK 0x0000000000000F00UL
0035 #define IBMVETH_ILLAN_IPV6_TCP_CSUM 0x0000000000000004UL
0036 #define IBMVETH_ILLAN_IPV4_TCP_CSUM 0x0000000000000002UL
0037 #define IBMVETH_ILLAN_ACTIVE_TRUNK 0x0000000000000001UL
0038
0039
0040 #define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \
0041 plpar_hcall_norets(H_REGISTER_LOGICAL_LAN, ua, buflst, rxq, fltlst, mac)
0042
0043 #define h_free_logical_lan(ua) \
0044 plpar_hcall_norets(H_FREE_LOGICAL_LAN, ua)
0045
0046 #define h_add_logical_lan_buffer(ua, buf) \
0047 plpar_hcall_norets(H_ADD_LOGICAL_LAN_BUFFER, ua, buf)
0048
0049 static inline long h_send_logical_lan(unsigned long unit_address,
0050 unsigned long desc1, unsigned long desc2, unsigned long desc3,
0051 unsigned long desc4, unsigned long desc5, unsigned long desc6,
0052 unsigned long corellator_in, unsigned long *corellator_out,
0053 unsigned long mss, unsigned long large_send_support)
0054 {
0055 long rc;
0056 unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
0057
0058 if (large_send_support)
0059 rc = plpar_hcall9(H_SEND_LOGICAL_LAN, retbuf, unit_address,
0060 desc1, desc2, desc3, desc4, desc5, desc6,
0061 corellator_in, mss);
0062 else
0063 rc = plpar_hcall9(H_SEND_LOGICAL_LAN, retbuf, unit_address,
0064 desc1, desc2, desc3, desc4, desc5, desc6,
0065 corellator_in);
0066
0067 *corellator_out = retbuf[0];
0068
0069 return rc;
0070 }
0071
0072 static inline long h_illan_attributes(unsigned long unit_address,
0073 unsigned long reset_mask, unsigned long set_mask,
0074 unsigned long *ret_attributes)
0075 {
0076 long rc;
0077 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
0078
0079 rc = plpar_hcall(H_ILLAN_ATTRIBUTES, retbuf, unit_address,
0080 reset_mask, set_mask);
0081
0082 *ret_attributes = retbuf[0];
0083
0084 return rc;
0085 }
0086
0087 #define h_multicast_ctrl(ua, cmd, mac) \
0088 plpar_hcall_norets(H_MULTICAST_CTRL, ua, cmd, mac)
0089
0090 #define h_change_logical_lan_mac(ua, mac) \
0091 plpar_hcall_norets(H_CHANGE_LOGICAL_LAN_MAC, ua, mac)
0092
0093 #define IBMVETH_NUM_BUFF_POOLS 5
0094 #define IBMVETH_IO_ENTITLEMENT_DEFAULT 4243456
0095 #define IBMVETH_BUFF_OH 22
0096 #define IBMVETH_MIN_MTU 68
0097 #define IBMVETH_MAX_POOL_COUNT 4096
0098 #define IBMVETH_BUFF_LIST_SIZE 4096
0099 #define IBMVETH_FILT_LIST_SIZE 4096
0100 #define IBMVETH_MAX_BUF_SIZE (1024 * 128)
0101
0102 static int pool_size[] = { 512, 1024 * 2, 1024 * 16, 1024 * 32, 1024 * 64 };
0103 static int pool_count[] = { 256, 512, 256, 256, 256 };
0104 static int pool_count_cmo[] = { 256, 512, 256, 256, 64 };
0105 static int pool_active[] = { 1, 1, 0, 0, 1};
0106
0107 #define IBM_VETH_INVALID_MAP ((u16)0xffff)
0108
0109 struct ibmveth_buff_pool {
0110 u32 size;
0111 u32 index;
0112 u32 buff_size;
0113 u32 threshold;
0114 atomic_t available;
0115 u32 consumer_index;
0116 u32 producer_index;
0117 u16 *free_map;
0118 dma_addr_t *dma_addr;
0119 struct sk_buff **skbuff;
0120 int active;
0121 struct kobject kobj;
0122 };
0123
0124 struct ibmveth_rx_q {
0125 u64 index;
0126 u64 num_slots;
0127 u64 toggle;
0128 dma_addr_t queue_dma;
0129 u32 queue_len;
0130 struct ibmveth_rx_q_entry *queue_addr;
0131 };
0132
0133 struct ibmveth_adapter {
0134 struct vio_dev *vdev;
0135 struct net_device *netdev;
0136 struct napi_struct napi;
0137 unsigned int mcastFilterSize;
0138 void * buffer_list_addr;
0139 void * filter_list_addr;
0140 dma_addr_t buffer_list_dma;
0141 dma_addr_t filter_list_dma;
0142 struct ibmveth_buff_pool rx_buff_pool[IBMVETH_NUM_BUFF_POOLS];
0143 struct ibmveth_rx_q rx_queue;
0144 int pool_config;
0145 int rx_csum;
0146 int large_send;
0147 bool is_active_trunk;
0148 void *bounce_buffer;
0149 dma_addr_t bounce_buffer_dma;
0150
0151 u64 fw_ipv6_csum_support;
0152 u64 fw_ipv4_csum_support;
0153 u64 fw_large_send_support;
0154
0155 u64 replenish_task_cycles;
0156 u64 replenish_no_mem;
0157 u64 replenish_add_buff_failure;
0158 u64 replenish_add_buff_success;
0159 u64 rx_invalid_buffer;
0160 u64 rx_no_buffer;
0161 u64 tx_map_failed;
0162 u64 tx_send_failed;
0163 u64 tx_large_packets;
0164 u64 rx_large_packets;
0165
0166 u8 duplex;
0167 u32 speed;
0168 };
0169
0170
0171
0172
0173
0174
0175
0176
0177 struct ibmveth_buf_desc_fields {
0178 #ifdef __BIG_ENDIAN
0179 u32 flags_len;
0180 u32 address;
0181 #else
0182 u32 address;
0183 u32 flags_len;
0184 #endif
0185 #define IBMVETH_BUF_VALID 0x80000000
0186 #define IBMVETH_BUF_TOGGLE 0x40000000
0187 #define IBMVETH_BUF_LRG_SND 0x04000000
0188 #define IBMVETH_BUF_NO_CSUM 0x02000000
0189 #define IBMVETH_BUF_CSUM_GOOD 0x01000000
0190 #define IBMVETH_BUF_LEN_MASK 0x00FFFFFF
0191 };
0192
0193 union ibmveth_buf_desc {
0194 u64 desc;
0195 struct ibmveth_buf_desc_fields fields;
0196 };
0197
0198 struct ibmveth_rx_q_entry {
0199 __be32 flags_off;
0200 #define IBMVETH_RXQ_TOGGLE 0x80000000
0201 #define IBMVETH_RXQ_TOGGLE_SHIFT 31
0202 #define IBMVETH_RXQ_VALID 0x40000000
0203 #define IBMVETH_RXQ_LRG_PKT 0x04000000
0204 #define IBMVETH_RXQ_NO_CSUM 0x02000000
0205 #define IBMVETH_RXQ_CSUM_GOOD 0x01000000
0206 #define IBMVETH_RXQ_OFF_MASK 0x0000FFFF
0207
0208 __be32 length;
0209
0210 u64 correlator;
0211 };
0212
0213 #endif