Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174303365
D58258.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D58258.diff
View Options
Index: sys/dev/dpaa2/dpaa2_ni.c
===================================================================
--- sys/dev/dpaa2/dpaa2_ni.c
+++ sys/dev/dpaa2/dpaa2_ni.c
@@ -95,6 +95,7 @@
#include "dpaa2_swp.h"
#include "dpaa2_swp_if.h"
#include "dpaa2_cmd_if.h"
+#include "sff_if.h"
#include "dpaa2_ni.h"
#include "dpaa2_channel.h"
#include "dpaa2_buf.h"
@@ -2598,6 +2599,48 @@
if_qflush(ifp);
}
+/*
+ * SFP+ EEPROM access for SIOCGI2C, so "ifconfig -v <dpni>" can show the
+ * module's SFF-8472 identity and diagnostics.
+ *
+ * The transceiver is a device in its own right: firmware names it in the
+ * DPMAC's node -- an "sfp" phandle under FDT, an "sfp" _DSD reference under
+ * ACPI -- and sff(4) drives it. All this handler does is ask the MC bus for
+ * that device and read from it; it knows neither how the module is wired up
+ * nor which flavour of firmware described it.
+ */
+static int
+dpaa2_ni_sfp_ioctl(struct dpaa2_ni_softc *sc, struct ifreq *ifr)
+{
+ struct ifi2creq req;
+ device_t sffdev;
+ int error;
+
+ error = copyin(ifr_data_get_ptr(ifr), &req, sizeof(req));
+ if (error != 0)
+ return (error);
+ if (req.dev_addr != 0xa0 && req.dev_addr != 0xa2)
+ return (EINVAL);
+ if (req.len == 0 || req.len > (int)sizeof(req.data))
+ return (EINVAL);
+ if ((u_int)req.offset + req.len > 256)
+ return (EINVAL);
+
+ sffdev = NULL;
+ error = DPAA2_MC_GET_SFF_DEV(sc->dev, &sffdev, sc->mac.dpmac_id);
+ if (error != 0)
+ return (error);
+ if (sffdev == NULL)
+ return (ENXIO);
+
+ error = SFF_READ_EEPROM(sffdev, req.dev_addr, req.offset, req.data,
+ req.len);
+ if (error != 0)
+ return (error);
+
+ return (copyout(&req, ifr_data_get_ptr(ifr), sizeof(req)));
+}
+
static int
dpaa2_ni_ioctl(if_t ifp, u_long c, caddr_t data)
{
@@ -2613,6 +2656,13 @@
uint16_t rc_token, ni_token;
int mtu, error, rc = 0;
+ /*
+ * The transceiver's EEPROM is on an i2c bus, not behind the MC, so
+ * answer that one before opening any MC object.
+ */
+ if (c == SIOCGI2C)
+ return (dpaa2_ni_sfp_ioctl(sc, ifr));
+
DPAA2_CMD_INIT(&cmd);
error = DPAA2_CMD_RC_OPEN(dev, child, &cmd, rcinfo->id, &rc_token);
@@ -3917,6 +3967,7 @@
DRIVER_MODULE(dpaa2_ni, dpaa2_rc, dpaa2_ni_driver, 0, 0);
MODULE_DEPEND(dpaa2_ni, miibus, 1, 1, 1);
+MODULE_DEPEND(dpaa2_ni, sff, 1, 1, 1);
#ifdef DEV_ACPI
MODULE_DEPEND(dpaa2_ni, memac_mdio_acpi, 1, 1, 1);
#endif
Index: sys/modules/dpaa2/Makefile
===================================================================
--- sys/modules/dpaa2/Makefile
+++ sys/modules/dpaa2/Makefile
@@ -19,6 +19,9 @@
SRCS+= dpaa2_cmd_if.c dpaa2_cmd_if.h
SRCS+= dpaa2_swp_if.c dpaa2_swp_if.h
SRCS+= dpaa2_mc_if.c dpaa2_mc_if.h
+# sff_if.h only: sff_if.c lives in sff.ko, adding it here would
+# duplicate the kobj descriptors.
+SRCS+= sff_if.h
SRCS+= memac_mdio_common.c memac_mdio_if.c memac_mdio_if.h
SRCS+= dpaa2_console.c
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 3, 5:06 AM (14 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40052258
Default Alt Text
D58258.diff (2 KB)
Attached To
Mode
D58258: dpaa2: read SFP+ module EEPROM through SIOCGI2C
Attached
Detach File
Event Timeline
Log In to Comment