Added support for the SIOCGI2C ioctl.

Submitted by:	Ram Kishore Vegesna <ram.vegesna@broadcom.com>
Obtained from:	Broadcom
MFC after:	2 weeks
This commit is contained in:
delphij 2019-01-08 05:41:04 +00:00
parent d1271e2362
commit aa320c199b
4 changed files with 40 additions and 6 deletions

View File

@ -475,6 +475,8 @@ oce_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
{
struct ifreq *ifr = (struct ifreq *)data;
POCE_SOFTC sc = ifp->if_softc;
struct ifi2creq i2c;
uint8_t offset = 0;
int rc = 0;
uint32_t u;
@ -586,6 +588,38 @@ oce_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
break;
case SIOCGI2C:
rc = copyin(ifr_data_get_ptr(ifr), &i2c, sizeof(i2c));
if (rc)
break;
if (i2c.dev_addr != PAGE_NUM_A0 &&
i2c.dev_addr != PAGE_NUM_A2) {
rc = EINVAL;
break;
}
if (i2c.len > sizeof(i2c.data)) {
rc = EINVAL;
break;
}
rc = oce_mbox_read_transrecv_data(sc, i2c.dev_addr);
if(rc) {
rc = -rc;
break;
}
if (i2c.dev_addr == PAGE_NUM_A0)
offset = i2c.offset;
else
offset = TRANSCEIVER_A0_SIZE + i2c.offset;
memcpy(&i2c.data[0], &sfp_vpd_dump_buffer[offset], i2c.len);
rc = copyout(&i2c, ifr_data_get_ptr(ifr), sizeof(i2c));
break;
case SIOCGPRIVATE_0:
rc = oce_handle_passthrough(ifp, data);
break;

View File

@ -1188,6 +1188,7 @@ static inline int MPU_EP_SEMAPHORE(POCE_SOFTC sc)
#define PAGE_NUM_A2 0xa2
#define IS_QNQ_OR_UMC(sc) ((sc->pvid && (sc->function_mode & FNM_UMC_MODE ))\
|| (sc->qnqid && (sc->function_mode & FNM_FLEX10_MODE)))
extern uint8_t sfp_vpd_dump_buffer[TRANSCEIVER_DATA_SIZE];
struct oce_rdma_info;
extern struct oce_rdma_if *oce_rdma_if;

View File

@ -41,7 +41,6 @@
/* $FreeBSD$ */
#include "oce_if.h"
extern uint32_t sfp_vpd_dump_buffer[TRANSCEIVER_DATA_NUM_ELE];
int
oce_wait_ready(POCE_SOFTC sc)
@ -1966,15 +1965,15 @@ oce_mbox_read_transrecv_data(POCE_SOFTC sc, uint32_t page_num)
if(fwcmd->params.rsp.page_num == PAGE_NUM_A0)
{
bcopy((char *)fwcmd->params.rsp.page_data,
(char *)&sfp_vpd_dump_buffer[0],
TRANSCEIVER_A0_SIZE);
&sfp_vpd_dump_buffer[0],
TRANSCEIVER_A0_SIZE);
}
if(fwcmd->params.rsp.page_num == PAGE_NUM_A2)
{
bcopy((char *)fwcmd->params.rsp.page_data,
(char *)&sfp_vpd_dump_buffer[32],
TRANSCEIVER_A2_SIZE);
&sfp_vpd_dump_buffer[TRANSCEIVER_A0_SIZE],
TRANSCEIVER_A2_SIZE);
}
error:
oce_dma_free(sc, &dma);

View File

@ -66,7 +66,7 @@ static void oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
extern char component_revision[32];
uint32_t sfp_vpd_dump_buffer[TRANSCEIVER_DATA_NUM_ELE];
uint8_t sfp_vpd_dump_buffer[TRANSCEIVER_DATA_SIZE];
struct flash_img_attri {
int img_offset;