2
2
* Misc useful os-independent macros and functions.
4
* Copyright 2008, Broadcom Corporation
4
* Copyright (C) 2010, Broadcom Corporation
5
5
* All Rights Reserved.
7
* Unless you and Broadcom execute a separate written software license
8
* agreement governing use of this software, this software is licensed to you
9
* under the terms of the GNU General Public License version 2, available at
10
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL"), with the
11
* following added to such license:
12
* As a special exception, the copyright holders of this software give you
13
* permission to link this software with independent modules, regardless of the
14
* license terms of these independent modules, and to copy and distribute the
15
* resulting executable under terms of your choice, provided that you also meet,
16
* for each linked independent module, the terms and conditions of the license
17
* of that module. An independent module is a module which is not derived from
20
7
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
21
8
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
22
9
* SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
23
10
* FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
25
* $Id: bcmutils.h,v 13.199.2.5 2008/11/25 12:13:46 Exp $
12
* $Id: bcmutils.h,v 13.217 2009/05/14 22:33:52 Exp $
28
15
#ifndef _bcmutils_h_
29
16
#define _bcmutils_h_
31
22
#define _BCM_U 0x01
32
23
#define _BCM_L 0x02
33
24
#define _BCM_D 0x04
108
99
#define PKTQ_PREC_ITER(pq, prec) for (prec = (pq)->num_prec - 1; prec >= 0; prec--)
101
typedef bool (*ifpkt_cb_t)(void*, int);
110
103
struct ether_addr;
112
105
#define pktq_psetmax(pq, prec, _max) ((pq)->q[prec].max = (_max))
123
116
extern void *pktq_pdeq(struct pktq *pq, int prec);
124
117
extern void *pktq_pdeq_tail(struct pktq *pq, int prec);
126
extern void pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir);
119
extern void pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir,
120
ifpkt_cb_t fn, int arg);
128
122
extern bool pktq_pdel(struct pktq *pq, void *p, int prec);
148
142
extern void *pktq_deq_tail(struct pktq *pq, int *prec_out);
149
143
extern void *pktq_peek(struct pktq *pq, int *prec_out);
150
144
extern void *pktq_peek_tail(struct pktq *pq, int *prec_out);
151
extern void pktq_flush(osl_t *osh, struct pktq *pq, bool dir);
145
extern void pktq_flush(osl_t *osh, struct pktq *pq, bool dir, ifpkt_cb_t fn, int arg);
153
147
extern uint pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf);
154
148
extern uint pktfrombuf(osl_t *osh, void *p, uint offset, int len, uchar *buf);
168
162
extern char *BCMROMFN(bcmstrcat)(char *dest, const char *src);
169
163
extern char *BCMROMFN(bcmstrncat)(char *dest, const char *src, uint size);
170
164
extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen);
165
char* bcmstrtok(char **string, const char *delimiters, char *tokdelim);
166
int bcmstricmp(const char *s1, const char *s2);
167
int bcmstrnicmp(const char* s1, const char* s2, int cnt);
172
169
extern char *bcm_ether_ntoa(const struct ether_addr *ea, char *buf);
173
170
extern int BCMROMFN(bcm_ether_atoe)(char *p, struct ether_addr *ea);
446
xor_128bit_block(const uint8 *src1, const uint8 *src2, uint8 *dst)
452
(((uintptr)src1 | (uintptr)src2 | (uintptr)dst) & 3) == 0) {
454
((uint32 *)dst)[0] = ((const uint32 *)src1)[0] ^ ((const uint32 *)src2)[0];
455
((uint32 *)dst)[1] = ((const uint32 *)src1)[1] ^ ((const uint32 *)src2)[1];
456
((uint32 *)dst)[2] = ((const uint32 *)src1)[2] ^ ((const uint32 *)src2)[2];
457
((uint32 *)dst)[3] = ((const uint32 *)src1)[3] ^ ((const uint32 *)src2)[3];
461
for (k = 0; k < 16; k++)
462
dst[k] = src1[k] ^ src2[k];
448
466
extern uint8 BCMROMFN(hndcrc8)(uint8 *p, uint nbytes, uint8 crc);
449
467
extern uint16 BCMROMFN(hndcrc16)(uint8 *p, uint nbytes, uint16 crc);
450
468
extern uint32 BCMROMFN(hndcrc32)(uint8 *p, uint nbytes, uint32 crc);
452
#if defined(BCMDBG) || defined(BCMDBG_ERR) || defined(BCMDBG_DUMP)
470
#if defined(BCMDBG) || defined(DHD_DEBUG) || defined(BCMDBG_ERR) || \
453
472
extern int bcm_format_flags(const bcm_bit_desc_t *bd, uint32 flags, char* buf, int len);
454
473
extern int bcm_format_hex(char *str, const void *bytes, int len);
455
474
extern void prhex(const char *msg, uchar *buf, uint len);
485
504
extern void bcm_binit(struct bcmstrbuf *b, char *buf, uint size);
486
505
extern int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...);
506
extern void bcm_inc_bytes(uchar *num, int num_bytes, uint8 amount);
507
extern int bcm_cmp_bytes(uchar *arg1, uchar *arg2, uint8 nbytes);
508
extern void bcm_print_bytes(char *name, const uchar *cdata, int len);
488
510
typedef uint32 (*bcmutl_rdreg_rtn)(void *arg0, uint arg1, uint32 offset);
489
511
extern uint bcmdumpfields(bcmutl_rdreg_rtn func_ptr, void *arg0, uint arg1, struct fielddesc *str,
492
514
extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len);
493
515
extern uint BCMROMFN(bcm_bitcount)(uint8 *bitmap, uint bytelength);