These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
This commit is contained in:
parent
0bdffa7573
commit
eddc22c9b4
|
@ -0,0 +1,140 @@
|
|||
#ifndef _JHASH_H
|
||||
#define _JHASH_H
|
||||
|
||||
/* jhash.h: Jenkins hash support.
|
||||
*
|
||||
* Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net)
|
||||
*
|
||||
* http://burtleburtle.net/bob/hash/
|
||||
*
|
||||
* These are the credits from Bob's sources:
|
||||
*
|
||||
* lookup2.c, by Bob Jenkins, December 1996, Public Domain.
|
||||
* hash(), hash2(), hash3, and mix() are externally useful functions.
|
||||
* Routines to test the hash are included if SELF_TEST is defined.
|
||||
* You can use this free for any purpose. It has no warranty.
|
||||
*
|
||||
* $FreeBSD: src/sys/dev/cxgb/common/jhash.h,v 1.1 2007/05/25 09:48:19 kmacy Exp $
|
||||
*/
|
||||
|
||||
/* NOTE: Arguments are modified. */
|
||||
#define __jhash_mix(a, b, c) \
|
||||
{ \
|
||||
a -= b; a -= c; a ^= (c>>13); \
|
||||
b -= c; b -= a; b ^= (a<<8); \
|
||||
c -= a; c -= b; c ^= (b>>13); \
|
||||
a -= b; a -= c; a ^= (c>>12); \
|
||||
b -= c; b -= a; b ^= (a<<16); \
|
||||
c -= a; c -= b; c ^= (b>>5); \
|
||||
a -= b; a -= c; a ^= (c>>3); \
|
||||
b -= c; b -= a; b ^= (a<<10); \
|
||||
c -= a; c -= b; c ^= (b>>15); \
|
||||
}
|
||||
|
||||
/* The golden ration: an arbitrary value */
|
||||
#define JHASH_GOLDEN_RATIO 0x9e3779b9
|
||||
|
||||
/* The most generic version, hashes an arbitrary sequence
|
||||
* of bytes. No alignment or length assumptions are made about
|
||||
* the input key.
|
||||
*/
|
||||
static inline u32 jhash(const void *key, u32 length, u32 initval)
|
||||
{
|
||||
u32 a, b, c, len;
|
||||
const u8 *k = key;
|
||||
|
||||
len = length;
|
||||
a = b = JHASH_GOLDEN_RATIO;
|
||||
c = initval;
|
||||
|
||||
while (len >= 12) {
|
||||
a += (k[0] +((u32)k[1]<<8) +((u32)k[2]<<16) +((u32)k[3]<<24));
|
||||
b += (k[4] +((u32)k[5]<<8) +((u32)k[6]<<16) +((u32)k[7]<<24));
|
||||
c += (k[8] +((u32)k[9]<<8) +((u32)k[10]<<16)+((u32)k[11]<<24));
|
||||
|
||||
__jhash_mix(a,b,c);
|
||||
|
||||
k += 12;
|
||||
len -= 12;
|
||||
}
|
||||
|
||||
c += length;
|
||||
switch (len) {
|
||||
case 11: c += ((u32)k[10]<<24);
|
||||
case 10: c += ((u32)k[9]<<16);
|
||||
case 9 : c += ((u32)k[8]<<8);
|
||||
case 8 : b += ((u32)k[7]<<24);
|
||||
case 7 : b += ((u32)k[6]<<16);
|
||||
case 6 : b += ((u32)k[5]<<8);
|
||||
case 5 : b += k[4];
|
||||
case 4 : a += ((u32)k[3]<<24);
|
||||
case 3 : a += ((u32)k[2]<<16);
|
||||
case 2 : a += ((u32)k[1]<<8);
|
||||
case 1 : a += k[0];
|
||||
};
|
||||
|
||||
__jhash_mix(a,b,c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/* A special optimized version that handles 1 or more of u32s.
|
||||
* The length parameter here is the number of u32s in the key.
|
||||
*/
|
||||
static inline u32 jhash2(u32 *k, u32 length, u32 initval)
|
||||
{
|
||||
u32 a, b, c, len;
|
||||
|
||||
a = b = JHASH_GOLDEN_RATIO;
|
||||
c = initval;
|
||||
len = length;
|
||||
|
||||
while (len >= 3) {
|
||||
a += k[0];
|
||||
b += k[1];
|
||||
c += k[2];
|
||||
__jhash_mix(a, b, c);
|
||||
k += 3; len -= 3;
|
||||
}
|
||||
|
||||
c += length * 4;
|
||||
|
||||
switch (len) {
|
||||
case 2 : b += k[1];
|
||||
case 1 : a += k[0];
|
||||
};
|
||||
|
||||
__jhash_mix(a,b,c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/* A special ultra-optimized versions that knows they are hashing exactly
|
||||
* 3, 2 or 1 word(s).
|
||||
*
|
||||
* NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
|
||||
* done at the end is not done here.
|
||||
*/
|
||||
static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
|
||||
{
|
||||
a += JHASH_GOLDEN_RATIO;
|
||||
b += JHASH_GOLDEN_RATIO;
|
||||
c += initval;
|
||||
|
||||
__jhash_mix(a, b, c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static inline u32 jhash_2words(u32 a, u32 b, u32 initval)
|
||||
{
|
||||
return jhash_3words(a, b, 0, initval);
|
||||
}
|
||||
|
||||
static inline u32 jhash_1word(u32 a, u32 initval)
|
||||
{
|
||||
return jhash_3words(a, 0, 0, initval);
|
||||
}
|
||||
|
||||
#endif /* _JHASH_H */
|
|
@ -0,0 +1,173 @@
|
|||
|
||||
/**************************************************************************
|
||||
|
||||
Copyright (c) 2007, Chelsio Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Neither the name of the Chelsio Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
$FreeBSD: src/sys/dev/cxgb/ulp/toecore/toedev.h,v 1.1 2007/05/25 16:17:59 kmacy Exp $
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _OFFLOAD_DEV_H_
|
||||
#define _OFFLOAD_DEV_H_
|
||||
|
||||
|
||||
/* Parameter values for offload_get_phys_egress() */
|
||||
enum {
|
||||
TOE_OPEN,
|
||||
TOE_FAILOVER,
|
||||
};
|
||||
|
||||
/* Parameter values for toe_failover() */
|
||||
enum {
|
||||
TOE_ACTIVE_SLAVE,
|
||||
TOE_LINK_DOWN,
|
||||
TOE_LINK_UP,
|
||||
TOE_RELEASE,
|
||||
TOE_RELEASE_ALL,
|
||||
};
|
||||
|
||||
|
||||
#define TOENAMSIZ 16
|
||||
|
||||
/* belongs in linux/netdevice.h */
|
||||
#define NETIF_F_TCPIP_OFFLOAD (1 << 15)
|
||||
|
||||
/* Get the toedev associated with a ifnet */
|
||||
#define TOEDEV(netdev) (*(struct toedev **)&(netdev)->if_softc)
|
||||
|
||||
/* offload type ids */
|
||||
enum {
|
||||
TOE_ID_CHELSIO_T1 = 1,
|
||||
TOE_ID_CHELSIO_T1C,
|
||||
TOE_ID_CHELSIO_T2,
|
||||
TOE_ID_CHELSIO_T3,
|
||||
TOE_ID_CHELSIO_T3B,
|
||||
};
|
||||
|
||||
struct offload_id {
|
||||
unsigned int id;
|
||||
unsigned long data;
|
||||
};
|
||||
|
||||
struct ifnet;
|
||||
struct rt_entry;
|
||||
struct tom_info;
|
||||
struct sysctl_oid;
|
||||
struct socket;
|
||||
struct mbuf;
|
||||
|
||||
enum toetype {
|
||||
T3A = 0,
|
||||
T3B
|
||||
};
|
||||
|
||||
}}}
|
||||
struct toedev {
|
||||
char name[TOENAMSIZ]; /* TOE device name */
|
||||
enum toetype type;
|
||||
struct adapter *adapter;
|
||||
unsigned int ttid; /* TOE type id */
|
||||
unsigned long flags; /* device flags */
|
||||
unsigned int mtu; /* max size of TX offloaded data */
|
||||
unsigned int nconn; /* max # of offloaded connections */
|
||||
struct ifnet *lldev; /* LL device associated with TOE messages */
|
||||
const struct tom_info *offload_mod; /* attached TCP offload module */
|
||||
struct sysctl_oid *sysctl_root; /* root of proc dir for this TOE */
|
||||
TAILQ_ENTRY(toedev) ofld_entry; /* for list linking */
|
||||
int (*open)(struct toedev *dev);
|
||||
int (*close)(struct toedev *dev);
|
||||
int (*can_offload)(struct toedev *dev, struct socket *so);
|
||||
int (*connect)(struct toedev *dev, struct socket *so,
|
||||
struct ifnet *egress_ifp);
|
||||
int (*send)(struct toedev *dev, struct mbuf *m);
|
||||
int (*recv)(struct toedev *dev, struct mbuf **m, int n);
|
||||
int (*ctl)(struct toedev *dev, unsigned int req, void *data);
|
||||
void (*neigh_update)(struct toedev *dev, struct rtentry *neigh);
|
||||
void (*failover)(struct toedev *dev, struct ifnet *bond_ifp,
|
||||
struct ifnet *ndev, int event);
|
||||
void *priv; /* driver private data */
|
||||
void *l2opt; /* optional layer 2 data */
|
||||
void *l3opt; /* optional layer 3 data */
|
||||
void *l4opt; /* optional layer 4 data */
|
||||
void *ulp; /* ulp stuff */
|
||||
};
|
||||
|
||||
struct tom_info {
|
||||
int (*attach)(struct toedev *dev, const struct offload_id *entry);
|
||||
int (*detach)(struct toedev *dev);
|
||||
const char *name;
|
||||
const struct offload_id *id_table;
|
||||
TAILQ_ENTRY(tom_info) entry;
|
||||
};
|
||||
|
||||
static inline void init_offload_dev(struct toedev *dev)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
extern int register_tom(struct tom_info *t);
|
||||
extern int unregister_tom(struct tom_info *t);
|
||||
extern int register_toedev(struct toedev *dev, const char *name);
|
||||
extern int unregister_toedev(struct toedev *dev);
|
||||
extern int activate_offload(struct toedev *dev);
|
||||
extern int toe_send(struct toedev *dev, struct mbuf *m);
|
||||
extern struct ifnet *offload_get_phys_egress(struct ifnet *dev,
|
||||
struct socket *so,
|
||||
int context);
|
||||
|
||||
#if defined(CONFIG_TCP_OFFLOAD_MODULE)
|
||||
static inline int toe_receive_mbuf(struct toedev *dev, struct mbuf **m,
|
||||
int n)
|
||||
{
|
||||
return dev->recv(dev, m, n);
|
||||
}
|
||||
|
||||
extern int prepare_tcp_for_offload(void);
|
||||
extern void restore_tcp_to_nonoffload(void);
|
||||
#elif defined(CONFIG_TCP_OFFLOAD)
|
||||
extern int toe_receive_mbuf(struct toedev *dev, struct mbuf **m, int n);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_TCP_OFFLOAD) || \
|
||||
(defined(CONFIG_TCP_OFFLOAD_MODULE) && defined(MODULE))
|
||||
extern void toe_neigh_update(struct rtentry *neigh);
|
||||
extern void toe_failover(struct ifnet *bond_ifp,
|
||||
struct ifnet *fail_ifp, int event);
|
||||
extern int toe_enslave(struct ifnet *bond_ifp,
|
||||
struct ifnet *slave_ifp);
|
||||
#else
|
||||
static inline void toe_neigh_update(struct ifnet *neigh) {}
|
||||
static inline void toe_failover(struct ifnet *bond_ifp,
|
||||
struct ifnet *fail_ifp, int event)
|
||||
{}
|
||||
static inline int toe_enslave(struct ifnet *bond_ifp,
|
||||
struct ifnet *slave_ifp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_TCP_OFFLOAD */
|
||||
|
||||
#endif /* _OFFLOAD_DEV_H_ */
|
Loading…
Reference in New Issue