Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
arch
tile
include
hv
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
{
33
HV_PhysAddr
pa
;
36
HV_PTE
pte
;
38
HV_VirtAddr
va
;
40
int
size
;
41
42
}
43
netio_ipp_address_t
;
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,
130
}
netio_hv_offset_t
;
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
{
145
uint64_t
addr
:48;
146
unsigned
int
class
:8;
147
unsigned
int
opcode
:8;
148
}
149
bits
;
150
uint64_t
word
;
151
}
152
__netio_getset_offset_t
;
153
157
typedef
enum
158
{
159
NETIO_FASTIO_ALLOCATE
= 0,
160
NETIO_FASTIO_FREE_BUFFER
= 1,
161
NETIO_FASTIO_RETURN_CREDITS
= 2,
162
NETIO_FASTIO_SEND_PKT_NOCK
= 3,
163
NETIO_FASTIO_SEND_PKT_CK
= 4,
164
NETIO_FASTIO_SEND_PKT_VEC
= 5,
165
NETIO_FASTIO_SENDV_PKT
= 6,
166
NETIO_FASTIO_NUM_INDEX
= 7,
167
}
netio_fastio_index_t
;
168
170
typedef
struct
171
{
172
int
err
;
173
uint32_t
val0
;
174
uint32_t
val1
;
175
}
netio_fastio_rv3_t
;
176
178
int
__netio_fastio0
(
uint32_t
fastio_index);
180
int
__netio_fastio1
(
uint32_t
fastio_index,
uint32_t
arg0);
182
netio_fastio_rv3_t
__netio_fastio3_rv3
(
uint32_t
fastio_index,
uint32_t
arg0,
183
uint32_t
arg1
,
uint32_t
arg2
);
185
int
__netio_fastio4
(
uint32_t
fastio_index,
uint32_t
arg0,
uint32_t
arg1
,
186
uint32_t
arg2
,
uint32_t
arg3
);
188
int
__netio_fastio6
(
uint32_t
fastio_index,
uint32_t
arg0,
uint32_t
arg1
,
189
uint32_t
arg2
,
uint32_t
arg3
,
uint32_t
arg4
,
uint32_t
arg5
);
191
int
__netio_fastio9
(
uint32_t
fastio_index,
uint32_t
arg0,
uint32_t
arg1
,
192
uint32_t
arg2
,
uint32_t
arg3
,
uint32_t
arg4
,
uint32_t
arg5
,
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
;
256
}
__netio_checksum_header_t
;
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
345
uint8_t
_unused
: 3;
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
372
uint8_t
cpa_hi
;
373
375
uint16_t
length
;
376
380
uint32_t
cpa_lo
;
381
383
__netio_checksum_header_t
checksum_data
;
384
385
}
lepp_cmd_t
;
386
387
389
typedef
struct
390
{
392
uint32_t
cpa_lo
;
394
uint16_t
cpa_hi : 15;
398
uint16_t
hash_for_home : 1;
400
uint16_t
length
;
401
}
lepp_frag_t
;
402
403
405
typedef
struct
406
{
412
uint8_t
tso : 1;
413
415
uint8_t
_unused
: 7;
416
424
uint8_t
header_size
;
425
427
uint8_t
ip_offset
;
428
430
uint8_t
tcp_offset
;
431
437
uint16_t
payload_size
;
438
440
uint16_t
num_frags
;
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
452
}
lepp_tso_cmd_t
;
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
548
char
cmds
[
LEPP_CMD_QUEUE_BYTES
]
549
__attribute__
((
aligned
(
CHIP_L2_LINE_SIZE
())));
550
554
lepp_comp_t
comps[
LEPP_COMP_QUEUE_SIZE
]
555
__attribute__
((
aligned
(
CHIP_L2_LINE_SIZE
())));
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__ */
Generated on Thu Jan 10 2013 13:18:58 for Linux Kernel by
1.8.2