Deleted Added
full compact
ethernet-sgmii.c (213150) ethernet-sgmii.c (215974)
1/*************************************************************************
2Copyright (c) 2003-2007 Cavium Networks (support@cavium.com). All rights
3reserved.
4
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are
8met:

--- 14 unchanged lines hidden (view full) ---

23This 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.
24
25TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
26AND 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.
27
28*************************************************************************/
29
30#include <sys/cdefs.h>
1/*************************************************************************
2Copyright (c) 2003-2007 Cavium Networks (support@cavium.com). All rights
3reserved.
4
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are
8met:

--- 14 unchanged lines hidden (view full) ---

23This 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.
24
25TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
26AND 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.
27
28*************************************************************************/
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet-sgmii.c 213150 2010-09-25 01:18:01Z jmallett $");
31__FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet-sgmii.c 215974 2010-11-28 05:57:24Z jmallett $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/bus.h>
36#include <sys/endian.h>
37#include <sys/kernel.h>
38#include <sys/mbuf.h>
39#include <sys/socket.h>
40
41#include <net/ethernet.h>
42#include <net/if.h>
43
44#include "wrapper-cvmx-includes.h"
45#include "ethernet-headers.h"
46
47extern int octeon_is_simulation(void);
48
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/bus.h>
36#include <sys/endian.h>
37#include <sys/kernel.h>
38#include <sys/mbuf.h>
39#include <sys/socket.h>
40
41#include <net/ethernet.h>
42#include <net/if.h>
43
44#include "wrapper-cvmx-includes.h"
45#include "ethernet-headers.h"
46
47extern int octeon_is_simulation(void);
48
49static int cvm_oct_sgmii_open(struct ifnet *ifp)
50{
51 cvmx_gmxx_prtx_cfg_t gmx_cfg;
52 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
53 int interface = INTERFACE(priv->port);
54 int index = INDEX(priv->port);
55 cvmx_helper_link_info_t link_info;
56
57 gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
58 gmx_cfg.s.en = 1;
59 cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
60
61 if (!octeon_is_simulation()) {
62 link_info = cvmx_helper_link_get(priv->port);
63 if (!link_info.s.link_up)
64 if_link_state_change(ifp, LINK_STATE_DOWN);
65 else
66 if_link_state_change(ifp, LINK_STATE_UP);
67 }
68
69 return 0;
70}
71
72static int cvm_oct_sgmii_stop(struct ifnet *ifp)
73{
74 cvmx_gmxx_prtx_cfg_t gmx_cfg;
75 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
76 int interface = INTERFACE(priv->port);
77 int index = INDEX(priv->port);
78
79 gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
80 gmx_cfg.s.en = 0;
81 cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
82 return 0;
83}
84
85static void cvm_oct_sgmii_poll(struct ifnet *ifp)
86{
87 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
88 cvmx_helper_link_info_t link_info;
89
90 link_info = cvmx_helper_link_get(priv->port);
91 if (link_info.u64 == priv->link_info)
92 return;
93
94 link_info = cvmx_helper_link_autoconf(priv->port);
95 priv->link_info = link_info.u64;
96 priv->need_link_update = 1;
97}
98
99int cvm_oct_sgmii_init(struct ifnet *ifp)
100{
101 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
102 cvm_oct_common_init(ifp);
49int cvm_oct_sgmii_init(struct ifnet *ifp)
50{
51 cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc;
52 cvm_oct_common_init(ifp);
103 priv->open = cvm_oct_sgmii_open;
104 priv->stop = cvm_oct_sgmii_stop;
53 priv->open = cvm_oct_common_open;
54 priv->stop = cvm_oct_common_stop;
105 priv->stop(ifp);
106 if (!octeon_is_simulation())
55 priv->stop(ifp);
56 if (!octeon_is_simulation())
107 priv->poll = cvm_oct_sgmii_poll;
57 priv->poll = cvm_oct_common_poll;
108
109 /* FIXME: Need autoneg logic */
110 return 0;
111}
58
59 /* FIXME: Need autoneg logic */
60 return 0;
61}
112
113void cvm_oct_sgmii_uninit(struct ifnet *ifp)
114{
115 cvm_oct_common_uninit(ifp);
116}
117