aboutsummaryrefslogtreecommitdiff
path: root/sys/mips/cavium/octe/cavium-ethernet.h
blob: cc19faf051e185e407519323ff95c42b11a8379c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*************************************************************************
Copyright (c) 2003-2007  Cavium Networks (support@cavium.com). All rights
reserved.


Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.

    * Neither the name of Cavium Networks 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, including technical data, may be subject to U.S. export  control laws, including the U.S. Export Administration Act and its  associated regulations, and may be subject to export or import  regulations in other countries.

TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
AND WITH ALL FAULTS AND CAVIUM  NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.

*************************************************************************/
/* $FreeBSD$ */

/**
 * @file
 * External interface for the Cavium Octeon ethernet driver.
 *
 * $Id: cavium-ethernet.h 41589 2009-03-19 19:58:58Z cchavva $
 *
 */
#ifndef CAVIUM_ETHERNET_H
#define CAVIUM_ETHERNET_H

#include <sys/taskqueue.h>
#include <net/if_media.h>
#include <net/ifq.h>

/**
 * This is the definition of the Ethernet driver's private
 * driver state stored in ifp->if_softc.
 */
typedef struct {
	/* XXX FreeBSD device softcs must start with an ifnet pointer.  */
	struct ifnet *ifp;

	int                     port;           /* PKO hardware output port */
	int                     queue;          /* PKO hardware queue for the port */
	int                     fau;            /* Hardware fetch and add to count outstanding tx buffers */
	int                     imode;          /* Type of port. This is one of the enums in cvmx_helper_interface_mode_t */
#if 0
	struct ifnet_stats stats;          /* Device statistics */
#endif
	uint64_t                link_info;      /* Last negotiated link state */
	void (*poll)(struct ifnet *ifp);   /* Called periodically to check link status */

	/*
	 * FreeBSD additions.
	 */
	device_t dev;
	device_t miibus;

	int (*open)(struct ifnet *ifp);
	int (*stop)(struct ifnet *ifp);

	int (*init)(struct ifnet *ifp);
	void (*uninit)(struct ifnet *ifp);

	uint8_t mac[6];
	int phy_id;
	const char *phy_device;
	int (*mdio_read)(struct ifnet *, int, int);
	void (*mdio_write)(struct ifnet *, int, int, int);

	struct ifqueue tx_free_queue[16];

	int need_link_update;
	struct task link_task;
	struct ifmedia media;
	int if_flags;

	struct mtx tx_mtx;
} cvm_oct_private_t;


/**
 * Free a work queue entry received in a intercept callback.
 *
 * @param work_queue_entry
 *               Work queue entry to free
 * @return Zero on success, Negative on failure.
 */
int cvm_oct_free_work(void *work_queue_entry);

#endif