1210311Sjmallett/*************************************************************************
2210311SjmallettCopyright (c) 2003-2007  Cavium Networks (support@cavium.com). All rights
3210311Sjmallettreserved.
4210311Sjmallett
5210311Sjmallett
6210311SjmallettRedistribution and use in source and binary forms, with or without
7210311Sjmallettmodification, are permitted provided that the following conditions are
8210311Sjmallettmet:
9210311Sjmallett
10210311Sjmallett    * Redistributions of source code must retain the above copyright
11210311Sjmallett      notice, this list of conditions and the following disclaimer.
12210311Sjmallett
13210311Sjmallett    * Redistributions in binary form must reproduce the above
14210311Sjmallett      copyright notice, this list of conditions and the following
15210311Sjmallett      disclaimer in the documentation and/or other materials provided
16210311Sjmallett      with the distribution.
17210311Sjmallett
18210311Sjmallett    * Neither the name of Cavium Networks nor the names of
19210311Sjmallett      its contributors may be used to endorse or promote products
20210311Sjmallett      derived from this software without specific prior written
21210311Sjmallett      permission.
22210311Sjmallett
23210311SjmallettThis 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.
24210311Sjmallett
25210311SjmallettTO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
26210311SjmallettAND 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.
27210311Sjmallett
28210311Sjmallett*************************************************************************/
29210311Sjmallett/* $FreeBSD$ */
30210311Sjmallett
31210311Sjmallett/**
32210311Sjmallett * @file
33210311Sjmallett * External interface for the Cavium Octeon ethernet driver.
34210311Sjmallett *
35210311Sjmallett * $Id: cavium-ethernet.h 41589 2009-03-19 19:58:58Z cchavva $
36210311Sjmallett *
37210311Sjmallett */
38210311Sjmallett#ifndef CAVIUM_ETHERNET_H
39210311Sjmallett#define CAVIUM_ETHERNET_H
40210311Sjmallett
41210311Sjmallett#include <net/if_media.h>
42210311Sjmallett
43210311Sjmallett/**
44210311Sjmallett * This is the definition of the Ethernet driver's private
45210311Sjmallett * driver state stored in ifp->if_softc.
46210311Sjmallett */
47210311Sjmalletttypedef struct {
48210311Sjmallett	/* XXX FreeBSD device softcs must start with an ifnet pointer.  */
49210311Sjmallett	struct ifnet *ifp;
50210311Sjmallett
51210311Sjmallett	int                     port;           /* PKO hardware output port */
52210311Sjmallett	int                     queue;          /* PKO hardware queue for the port */
53210311Sjmallett	int                     fau;            /* Hardware fetch and add to count outstanding tx buffers */
54210311Sjmallett	int                     imode;          /* Type of port. This is one of the enums in cvmx_helper_interface_mode_t */
55210311Sjmallett#if 0
56210311Sjmallett	struct ifnet_stats stats;          /* Device statistics */
57210311Sjmallett#endif
58210311Sjmallett	uint64_t                link_info;      /* Last negotiated link state */
59210311Sjmallett	void (*poll)(struct ifnet *ifp);   /* Called periodically to check link status */
60210311Sjmallett
61210311Sjmallett	/*
62210311Sjmallett	 * FreeBSD additions.
63210311Sjmallett	 */
64210311Sjmallett	device_t dev;
65210311Sjmallett	device_t miibus;
66210311Sjmallett
67210311Sjmallett	int (*open)(struct ifnet *ifp);
68210311Sjmallett	int (*stop)(struct ifnet *ifp);
69210311Sjmallett
70210311Sjmallett	int (*init)(struct ifnet *ifp);
71210311Sjmallett	void (*uninit)(struct ifnet *ifp);
72210311Sjmallett
73210311Sjmallett	uint8_t mac[6];
74210311Sjmallett	int phy_id;
75213762Sjmallett	const char *phy_device;
76213346Sjmallett	int (*mdio_read)(struct ifnet *, int, int);
77213346Sjmallett	void (*mdio_write)(struct ifnet *, int, int, int);
78210311Sjmallett
79210311Sjmallett	struct ifqueue tx_free_queue[16];
80210311Sjmallett
81213150Sjmallett	int need_link_update;
82213150Sjmallett	struct task link_task;
83210311Sjmallett	struct ifmedia media;
84210311Sjmallett	int if_flags;
85210311Sjmallett
86210311Sjmallett	struct mtx tx_mtx;
87210311Sjmallett} cvm_oct_private_t;
88210311Sjmallett
89210311Sjmallett
90210311Sjmallett/**
91210311Sjmallett * Free a work queue entry received in a intercept callback.
92210311Sjmallett *
93210311Sjmallett * @param work_queue_entry
94210311Sjmallett *               Work queue entry to free
95210311Sjmallett * @return Zero on success, Negative on failure.
96210311Sjmallett */
97210311Sjmallettint cvm_oct_free_work(void *work_queue_entry);
98210311Sjmallett
99210311Sjmallett#endif
100