oce_sysctl.c (231879) | oce_sysctl.c (247880) |
---|---|
1/*- 2 * Copyright (C) 2012 Emulex 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, --- 22 unchanged lines hidden (view full) --- 31 * Contact Information: 32 * freebsd-drivers@emulex.com 33 * 34 * Emulex 35 * 3333 Susan Street 36 * Costa Mesa, CA 92626 37 */ 38 | 1/*- 2 * Copyright (C) 2012 Emulex 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, --- 22 unchanged lines hidden (view full) --- 31 * Contact Information: 32 * freebsd-drivers@emulex.com 33 * 34 * Emulex 35 * 3333 Susan Street 36 * Costa Mesa, CA 92626 37 */ 38 |
39/* $FreeBSD: head/sys/dev/oce/oce_sysctl.c 231879 2012-02-17 13:55:17Z luigi $ */ | 39/* $FreeBSD: head/sys/dev/oce/oce_sysctl.c 247880 2013-03-06 09:53:38Z delphij $ */ |
40 | 40 |
41/* $FreeBSD: head/sys/dev/oce/oce_sysctl.c 247880 2013-03-06 09:53:38Z delphij $ */ 42 43 |
|
41#include "oce_if.h" 42 43static void copy_stats_to_sc_xe201(POCE_SOFTC sc); 44static void copy_stats_to_sc_be3(POCE_SOFTC sc); 45static void copy_stats_to_sc_be2(POCE_SOFTC sc); 46static int oce_sysctl_loopback(SYSCTL_HANDLER_ARGS); 47static int oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw); 48static int oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS); 49static int oce_be3_flashdata(POCE_SOFTC sc, const struct firmware 50 *fw, int num_imgs); 51static int oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw); | 44#include "oce_if.h" 45 46static void copy_stats_to_sc_xe201(POCE_SOFTC sc); 47static void copy_stats_to_sc_be3(POCE_SOFTC sc); 48static void copy_stats_to_sc_be2(POCE_SOFTC sc); 49static int oce_sysctl_loopback(SYSCTL_HANDLER_ARGS); 50static int oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw); 51static int oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS); 52static int oce_be3_flashdata(POCE_SOFTC sc, const struct firmware 53 *fw, int num_imgs); 54static int oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw); |
55static int oce_sysctl_sfp_vpd_dump(SYSCTL_HANDLER_ARGS); |
|
52static boolean_t oce_phy_flashing_required(POCE_SOFTC sc); 53static boolean_t oce_img_flashing_required(POCE_SOFTC sc, const char *p, 54 int img_optype, uint32_t img_offset, 55 uint32_t img_size, uint32_t hdrs_size); 56static void oce_add_stats_sysctls_be3(POCE_SOFTC sc, 57 struct sysctl_ctx_list *ctx, 58 struct sysctl_oid *stats_node); 59static void oce_add_stats_sysctls_xe201(POCE_SOFTC sc, 60 struct sysctl_ctx_list *ctx, 61 struct sysctl_oid *stats_node); 62 63extern char component_revision[32]; | 56static boolean_t oce_phy_flashing_required(POCE_SOFTC sc); 57static boolean_t oce_img_flashing_required(POCE_SOFTC sc, const char *p, 58 int img_optype, uint32_t img_offset, 59 uint32_t img_size, uint32_t hdrs_size); 60static void oce_add_stats_sysctls_be3(POCE_SOFTC sc, 61 struct sysctl_ctx_list *ctx, 62 struct sysctl_oid *stats_node); 63static void oce_add_stats_sysctls_xe201(POCE_SOFTC sc, 64 struct sysctl_ctx_list *ctx, 65 struct sysctl_oid *stats_node); 66 67extern char component_revision[32]; |
68uint32_t sfp_vpd_dump_buffer[TRANSCEIVER_DATA_NUM_ELE]; |
|
64 | 69 |
65 | |
66void 67oce_add_sysctls(POCE_SOFTC sc) 68{ 69 70 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev); 71 struct sysctl_oid *tree = device_get_sysctl_tree(sc->dev); 72 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree); 73 struct sysctl_oid *stats_node; --- 14 unchanged lines hidden (view full) --- 88 89 SYSCTL_ADD_INT(ctx, child, 90 OID_AUTO, "max_rsp_handled", 91 CTLTYPE_INT | CTLFLAG_RW, 92 &oce_max_rsp_handled, 93 sizeof(oce_max_rsp_handled), 94 "Maximum receive frames handled per interupt"); 95 | 70void 71oce_add_sysctls(POCE_SOFTC sc) 72{ 73 74 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev); 75 struct sysctl_oid *tree = device_get_sysctl_tree(sc->dev); 76 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree); 77 struct sysctl_oid *stats_node; --- 14 unchanged lines hidden (view full) --- 92 93 SYSCTL_ADD_INT(ctx, child, 94 OID_AUTO, "max_rsp_handled", 95 CTLTYPE_INT | CTLFLAG_RW, 96 &oce_max_rsp_handled, 97 sizeof(oce_max_rsp_handled), 98 "Maximum receive frames handled per interupt"); 99 |
96 if (sc->function_mode & FNM_FLEX10_MODE) | 100 if ((sc->function_mode & FNM_FLEX10_MODE) || 101 (sc->function_mode & FNM_UMC_MODE)) |
97 SYSCTL_ADD_UINT(ctx, child, 98 OID_AUTO, "speed", 99 CTLFLAG_RD, 100 &sc->qos_link_speed, 101 0,"QOS Speed"); 102 else 103 SYSCTL_ADD_UINT(ctx, child, 104 OID_AUTO, "speed", --- 11 unchanged lines hidden (view full) --- 116 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "loop_back", 117 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, 118 oce_sysctl_loopback, "I", "Loop Back Tests"); 119 120 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fw_upgrade", 121 CTLTYPE_STRING | CTLFLAG_RW, (void *)sc, 0, 122 oce_sys_fwupgrade, "A", "Firmware ufi file"); 123 | 102 SYSCTL_ADD_UINT(ctx, child, 103 OID_AUTO, "speed", 104 CTLFLAG_RD, 105 &sc->qos_link_speed, 106 0,"QOS Speed"); 107 else 108 SYSCTL_ADD_UINT(ctx, child, 109 OID_AUTO, "speed", --- 11 unchanged lines hidden (view full) --- 121 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "loop_back", 122 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, 123 oce_sysctl_loopback, "I", "Loop Back Tests"); 124 125 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fw_upgrade", 126 CTLTYPE_STRING | CTLFLAG_RW, (void *)sc, 0, 127 oce_sys_fwupgrade, "A", "Firmware ufi file"); 128 |
129 /* 130 * Dumps Transceiver data 131 * "sysctl dev.oce.0.sfp_vpd_dump=0" 132 * "sysctl -x dev.oce.0.sfp_vpd_dump_buffer" for hex dump 133 * "sysctl -b dev.oce.0.sfp_vpd_dump_buffer > sfp.bin" for binary dump 134 */ 135 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "sfp_vpd_dump", 136 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, oce_sysctl_sfp_vpd_dump, 137 "I", "Initiate a sfp_vpd_dump operation"); 138 SYSCTL_ADD_OPAQUE(ctx, child, OID_AUTO, "sfp_vpd_dump_buffer", 139 CTLFLAG_RD, sfp_vpd_dump_buffer, 140 TRANSCEIVER_DATA_SIZE, "IU", "Access sfp_vpd_dump buffer"); 141 |
|
124 stats_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", 125 CTLFLAG_RD, NULL, "Ethernet Statistics"); 126 127 if (IS_BE(sc)) 128 oce_add_stats_sysctls_be3(sc, ctx, stats_node); 129 else 130 oce_add_stats_sysctls_xe201(sc, ctx, stats_node); 131 132 133} 134 135 | 142 stats_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", 143 CTLFLAG_RD, NULL, "Ethernet Statistics"); 144 145 if (IS_BE(sc)) 146 oce_add_stats_sysctls_be3(sc, ctx, stats_node); 147 else 148 oce_add_stats_sysctls_xe201(sc, ctx, stats_node); 149 150 151} 152 153 |
136 | |
137static uint32_t 138oce_loopback_test(struct oce_softc *sc, uint8_t loopback_type) 139{ 140 uint32_t status = 0; 141 142 oce_mbox_cmd_set_loopback(sc, sc->if_id, loopback_type, 1); 143 status = oce_mbox_cmd_test_loopback(sc, sc->if_id, loopback_type, 144 1500, 2, 0xabc); 145 oce_mbox_cmd_set_loopback(sc, sc->if_id, OCE_NO_LOOPBACK, 1); 146 147 return status; 148} 149 | 154static uint32_t 155oce_loopback_test(struct oce_softc *sc, uint8_t loopback_type) 156{ 157 uint32_t status = 0; 158 159 oce_mbox_cmd_set_loopback(sc, sc->if_id, loopback_type, 1); 160 status = oce_mbox_cmd_test_loopback(sc, sc->if_id, loopback_type, 161 1500, 2, 0xabc); 162 oce_mbox_cmd_set_loopback(sc, sc->if_id, OCE_NO_LOOPBACK, 1); 163 164 return status; 165} 166 |
150 | |
151static int 152oce_sysctl_loopback(SYSCTL_HANDLER_ARGS) 153{ 154 int value = 0; 155 uint32_t status; 156 struct oce_softc *sc = (struct oce_softc *)arg1; 157 158 status = sysctl_handle_int(oidp, &value, 0, req); --- 1139 unchanged lines hidden (view full) --- 1298 } else { 1299 rc = oce_mbox_get_pport_stats(sc, &sc->stats_mem, reset); 1300 if (!rc) 1301 copy_stats_to_sc_xe201(sc); 1302 } 1303 1304 return rc; 1305} | 167static int 168oce_sysctl_loopback(SYSCTL_HANDLER_ARGS) 169{ 170 int value = 0; 171 uint32_t status; 172 struct oce_softc *sc = (struct oce_softc *)arg1; 173 174 status = sysctl_handle_int(oidp, &value, 0, req); --- 1139 unchanged lines hidden (view full) --- 1314 } else { 1315 rc = oce_mbox_get_pport_stats(sc, &sc->stats_mem, reset); 1316 if (!rc) 1317 copy_stats_to_sc_xe201(sc); 1318 } 1319 1320 return rc; 1321} |
1322 1323static int 1324oce_sysctl_sfp_vpd_dump(SYSCTL_HANDLER_ARGS) 1325{ 1326 int result = 0, error; 1327 int rc = 0; 1328 POCE_SOFTC sc = (POCE_SOFTC) arg1; 1329 1330 /* sysctl default handler */ 1331 error = sysctl_handle_int(oidp, &result, 0, req); 1332 if (error || !req->newptr) 1333 return (error); 1334 1335 if(result == -1) { 1336 return EINVAL; 1337 } 1338 bzero((char *)sfp_vpd_dump_buffer, TRANSCEIVER_DATA_SIZE); 1339 1340 rc = oce_mbox_read_transrecv_data(sc, PAGE_NUM_A0); 1341 if(rc) 1342 return rc; 1343 1344 rc = oce_mbox_read_transrecv_data(sc, PAGE_NUM_A2); 1345 if(rc) 1346 return rc; 1347 1348 return rc; 1349} |
|