Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
drv_xgbe_intf.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Tilera Corporation. All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation, version 2.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11  * NON INFRINGEMENT. See the GNU General Public License for
12  * more details.
13  */
14 
20 #ifndef __DRV_XGBE_INTF_H__
21 #define __DRV_XGBE_INTF_H__
22 
30 typedef struct
31 {
40  int size;
41 
42 }
44 
48 typedef enum
49 {
54  NETIO_FIXED_ADDR = 0x5000000000000000ULL,
55 
60  NETIO_FIXED_SIZE = 0x5100000000000000ULL,
61 
64  NETIO_IPP_INPUT_REGISTER_OFF = 0x6000000000000000ULL,
65 
67  NETIO_IPP_INPUT_UNREGISTER_OFF = 0x6100000000000000ULL,
68 
70  NETIO_IPP_INPUT_INIT_OFF = 0x6200000000000000ULL,
71 
73  NETIO_IPP_INPUT_UNINIT_OFF = 0x6300000000000000ULL,
74 
78  NETIO_IPP_INPUT_GROUP_CFG_OFF = 0x6400000000000000ULL,
79 
83  NETIO_IPP_INPUT_BUCKET_CFG_OFF = 0x6500000000000000ULL,
84 
87  NETIO_IPP_PARAM_OFF = 0x6600000000000000ULL,
88 
90  NETIO_IPP_GET_FASTIO_OFF = 0x6700000000000000ULL,
91 
95  NETIO_IPP_INPUT_HIJACK_CFG_OFF = 0x6800000000000000ULL,
96 
101  NETIO_IPP_USER_MAX_OFF = 0x6FFFFFFFFFFFFFFFULL,
102 
104  NETIO_IPP_IOMEM_REGISTER_OFF = 0x7000000000000000ULL,
105 
107  NETIO_IPP_IOMEM_UNREGISTER_OFF = 0x7100000000000000ULL,
108 
109  /* Offsets greater than 0x7FFFFFFF can't be used directly from Linux
110  * userspace code due to limitations in the pread/pwrite syscalls. */
111 
113  NETIO_IPP_DRAIN_OFF = 0xFA00000000000000ULL,
114 
117  NETIO_EPP_SHM_OFF = 0xFB00000000000000ULL,
118 
119  /* 0xFC... is currently unused. */
120 
122  NETIO_IPP_STOP_SHIM_OFF = 0xFD00000000000000ULL,
123 
125  NETIO_IPP_START_SHIM_OFF = 0xFE00000000000000ULL,
126 
129  NETIO_IPP_ADDRESS_OFF = 0xFF00000000000000ULL,
131 
133 #define NETIO_BASE_OFFSET(off) ((off) & 0xFF00000000000000ULL)
134 
135 #define NETIO_LOCAL_OFFSET(off) ((off) & 0x00FFFFFFFFFFFFFFULL)
136 
137 
141 typedef union
142 {
143  struct
144  {
146  unsigned int class:8;
147  unsigned int opcode:8;
148  }
149  bits;
151 }
153 
157 typedef enum
158 {
168 
170 typedef struct
171 {
172  int err;
176 
178 int __netio_fastio0(uint32_t fastio_index);
180 int __netio_fastio1(uint32_t fastio_index, uint32_t arg0);
185 int __netio_fastio4(uint32_t fastio_index, uint32_t arg0, uint32_t arg1,
188 int __netio_fastio6(uint32_t fastio_index, uint32_t arg0, uint32_t arg1,
191 int __netio_fastio9(uint32_t fastio_index, uint32_t arg0, uint32_t arg1,
193  uint32_t arg6, uint32_t arg7, uint32_t arg8);
194 
199 #define __netio_fastio_allocate(fastio_index, size) \
200  __netio_fastio1((fastio_index) + NETIO_FASTIO_ALLOCATE, size)
201 
206 #define __netio_fastio_free_buffer(fastio_index, handle) \
207  __netio_fastio1((fastio_index) + NETIO_FASTIO_FREE_BUFFER, handle)
208 
213 #define __netio_fastio_return_credits(fastio_index, credits) \
214  __netio_fastio1((fastio_index) + NETIO_FASTIO_RETURN_CREDITS, credits)
215 
223 #define __netio_fastio_send_pkt_nock(fastio_index, ackflag, size, va, handle) \
224  __netio_fastio4((fastio_index) + NETIO_FASTIO_SEND_PKT_NOCK, ackflag, \
225  size, va, handle)
226 
236 #define __netio_fastio_send_pkt_ck(fastio_index, ackflag, size, va, handle, \
237  csum0, csum1) \
238  __netio_fastio6((fastio_index) + NETIO_FASTIO_SEND_PKT_CK, ackflag, \
239  size, va, handle, csum0, csum1)
240 
241 
246 typedef union
247 {
248  struct
249  {
250  unsigned int start_byte:7;
251  unsigned int count:14;
252  unsigned int destination_byte:7;
253  unsigned int reserved:4;
254  } bits;
255  unsigned int word;
257 
258 
270 #define __netio_fastio_sendv_pkt_1_2(fastio_index, flags, confno, csum0, \
271  va_F, va_L, len_F_L) \
272  __netio_fastio6((fastio_index) + NETIO_FASTIO_SENDV_PKT, flags, confno, \
273  csum0, va_F, va_L, len_F_L)
274 
284 #define __netio_fastio_send_pcie_pkt(fastio_index, flags, confno, csum0, \
285  va_F, va_L, len_F_L) \
286  __netio_fastio6((fastio_index) + PCIE_FASTIO_SENDV_PKT, flags, confno, \
287  csum0, va_F, va_L, len_F_L)
288 
307 #define __netio_fastio_sendv_pkt_3_4(fastio_index, flags, confno, csum0, va_F, \
308  va_L, len_F_L, va_M0, va_M1, len_M0_M1) \
309  __netio_fastio9((fastio_index) + NETIO_FASTIO_SENDV_PKT, flags, confno, \
310  csum0, va_F, va_L, len_F_L, va_M0, va_M1, len_M0_M1)
311 
329 #define __netio_fastio_send_pkt_vec(fastio_index, seqno, nentries, va) \
330  __netio_fastio3_rv3((fastio_index) + NETIO_FASTIO_SEND_PKT_VEC, seqno, \
331  nentries, va)
332 
333 
335 typedef struct
336 {
342  uint8_t tso : 1;
343 
346 
350  uint8_t hash_for_home : 1;
351 
353  uint8_t compute_checksum : 1;
354 
361  uint8_t end_of_packet : 1;
362 
364  uint8_t send_completion : 1;
365 
373 
376 
381 
384 
385 } lepp_cmd_t;
386 
387 
389 typedef struct
390 {
394  uint16_t cpa_hi : 15;
398  uint16_t hash_for_home : 1;
401 } lepp_frag_t;
402 
403 
405 typedef struct
406 {
412  uint8_t tso : 1;
413 
416 
425 
428 
431 
438 
441 
443  lepp_frag_t frags[0 /* Variable-sized; num_frags entries. */];
444 
445  /*
446  * The packet header template logically follows frags[],
447  * but you can't declare that in C.
448  *
449  * uint32_t header[header_size_in_words_rounded_up];
450  */
451 
453 
454 
456 typedef void* lepp_comp_t;
457 
458 
463 #define LEPP_MAX_FRAGS (65536 / HV_DEFAULT_PAGE_SIZE_SMALL + 2 + 1)
464 
466 #define LEPP_TSO_CMD_SIZE(num_frags, header_size) \
467  (sizeof(lepp_tso_cmd_t) + \
468  (num_frags) * sizeof(lepp_frag_t) + \
469  (((header_size) + 3) & -4))
470 
472 #define LEPP_CMD_QUEUE_BYTES \
473  (((CHIP_L2_CACHE_SIZE() - 2 * CHIP_L2_LINE_SIZE()) / \
474  (sizeof(lepp_cmd_t) + sizeof(lepp_comp_t))) * sizeof(lepp_cmd_t))
475 
477 #define LEPP_MAX_CMD_SIZE LEPP_TSO_CMD_SIZE(LEPP_MAX_FRAGS, 128)
478 
481 #define LEPP_CMD_LIMIT \
482  (LEPP_CMD_QUEUE_BYTES - LEPP_MAX_CMD_SIZE)
483 
485 #define LEPP_COMP_QUEUE_SIZE \
486  ((LEPP_CMD_LIMIT + sizeof(lepp_cmd_t) - 1) / sizeof(lepp_cmd_t))
487 
489 #define LEPP_QINC(var) \
490  (var = __insn_mnz(var - (LEPP_COMP_QUEUE_SIZE - 1), var + 1))
491 
493 typedef struct
494 {
500  unsigned int comp_head;
501 
509  volatile unsigned int comp_busy;
510 
517  unsigned int comp_tail;
518 
532  volatile unsigned int cmd_head;
533 
542  volatile unsigned int cmd_tail;
543 
550 
556 } lepp_queue_t;
557 
558 
562 static inline unsigned int
563 _lepp_num_free_slots(unsigned int head, unsigned int tail)
564 {
565  /*
566  * One entry is reserved for use as a sentinel, to distinguish
567  * "empty" from "full". So we compute
568  * (head - tail - 1) % LEPP_QUEUE_SIZE, but without using a slow % operation.
569  */
570  return (head - tail - 1) + ((head <= tail) ? LEPP_COMP_QUEUE_SIZE : 0);
571 }
572 
573 
575 static inline unsigned int
576 lepp_num_free_comp_slots(const lepp_queue_t* q)
577 {
578  return _lepp_num_free_slots(q->comp_head, q->comp_tail);
579 }
580 
581 static inline int
582 lepp_qsub(int v1, int v2)
583 {
584  int delta = v1 - v2;
585  return delta + ((delta >> 31) & LEPP_COMP_QUEUE_SIZE);
586 }
587 
588 
590 #define LIPP_VERSION 1
591 
592 
594 #define LIPP_PACKET_PADDING 2
595 
597 #define LIPP_SMALL_PACKET_SIZE 128
598 
599 /*
600  * NOTE: The following two values should total to less than around
601  * 13582, to keep the total size used for "lipp_state_t" below 64K.
602  */
603 
608 #define LIPP_SMALL_BUFFERS 6785
609 
613 #define LIPP_LARGE_BUFFERS 6785
614 
615 #endif /* __DRV_XGBE_INTF_H__ */