Date: Tue, 22 Jan 2019 04:20:00 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r343299 - stable/12/sys/dev/oce Message-ID: <201901220420.x0M4K0oQ023418@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Tue Jan 22 04:20:00 2019 New Revision: 343299 URL: https://svnweb.freebsd.org/changeset/base/343299 Log: MFC r342856: Added support for the SIOCGI2C ioctl. Submitted by: Ram Kishore Vegesna <ram.vegesna@broadcom.com> Obtained from: Broadcom Modified: stable/12/sys/dev/oce/oce_if.c stable/12/sys/dev/oce/oce_if.h stable/12/sys/dev/oce/oce_mbox.c stable/12/sys/dev/oce/oce_sysctl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/oce/oce_if.c ============================================================================== --- stable/12/sys/dev/oce/oce_if.c Tue Jan 22 03:53:42 2019 (r343298) +++ stable/12/sys/dev/oce/oce_if.c Tue Jan 22 04:20:00 2019 (r343299) @@ -475,6 +475,8 @@ oce_ioctl(struct ifnet *ifp, u_long command, caddr_t d { 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; @@ -584,6 +586,38 @@ oce_ioctl(struct ifnet *ifp, u_long command, caddr_t d } #endif + 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: Modified: stable/12/sys/dev/oce/oce_if.h ============================================================================== --- stable/12/sys/dev/oce/oce_if.h Tue Jan 22 03:53:42 2019 (r343298) +++ stable/12/sys/dev/oce/oce_if.h Tue Jan 22 04:20:00 2019 (r343299) @@ -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; Modified: stable/12/sys/dev/oce/oce_mbox.c ============================================================================== --- stable/12/sys/dev/oce/oce_mbox.c Tue Jan 22 03:53:42 2019 (r343298) +++ stable/12/sys/dev/oce/oce_mbox.c Tue Jan 22 04:20:00 2019 (r343299) @@ -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 p 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); Modified: stable/12/sys/dev/oce/oce_sysctl.c ============================================================================== --- stable/12/sys/dev/oce/oce_sysctl.c Tue Jan 22 03:53:42 2019 (r343298) +++ stable/12/sys/dev/oce/oce_sysctl.c Tue Jan 22 04:20:00 2019 (r343299) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901220420.x0M4K0oQ023418>