Re: svn commit: r292639 - head/sys/dev/bxe

2015-12-23 Thread Marcelo Araujo
Hey,

I'm wondering what that means: bxe_is_wreg_in_chip(struct bxe_softc *sc,
const struct wreg_addr *wreg_info)

Wreg, what wreg means??

Best,
On Dec 23, 2015 11:19 AM, "David C Somayajulu"  wrote:

> Author: davidcs
> Date: Wed Dec 23 03:19:12 2015
> New Revision: 292639
> URL: https://svnweb.freebsd.org/changeset/base/292639
>
> Log:
>   Add support for firmware dump (a.k.a grcdump)
>
>   MFC after:5 days
>
> Added:
>   head/sys/dev/bxe/bxe_dump.h   (contents, props changed)
>   head/sys/dev/bxe/bxe_ioctl.h   (contents, props changed)
> Modified:
>   head/sys/dev/bxe/bxe.c
>   head/sys/dev/bxe/bxe.h
>   head/sys/dev/bxe/ecore_init.h
>
> Modified: head/sys/dev/bxe/bxe.c
>
> ==
> --- head/sys/dev/bxe/bxe.c  Wed Dec 23 01:31:32 2015(r292638)
> +++ head/sys/dev/bxe/bxe.c  Wed Dec 23 03:19:12 2015(r292639)
> @@ -736,6 +736,8 @@ static __noinline int bxe_nic_unload(str
>  static void bxe_handle_sp_tq(void *context, int pending);
>  static void bxe_handle_fp_tq(void *context, int pending);
>
> +static int bxe_add_cdev(struct bxe_softc *sc);
> +static void bxe_del_cdev(struct bxe_softc *sc);
>
>  /* calculate crc32 on a buffer (NOTE: crc32_length MUST be aligned to 8)
> */
>  uint32_t
> @@ -4503,7 +4505,7 @@ bxe_nic_unload(struct bxe_softc *sc,
>  sc->rx_mode = BXE_RX_MODE_NONE;
>  /* XXX set rx mode ??? */
>
> -if (IS_PF(sc)) {
> +if (IS_PF(sc) && !sc->grcdump_done) {
>  /* set ALWAYS_ALIVE bit in shmem */
>  sc->fw_drv_pulse_wr_seq |= DRV_PULSE_ALWAYS_ALIVE;
>
> @@ -4523,7 +4525,8 @@ bxe_nic_unload(struct bxe_softc *sc,
>  ; /* bxe_vfpf_close_vf(sc); */
>  } else if (unload_mode != UNLOAD_RECOVERY) {
>  /* if this is a normal/close unload need to clean up chip */
> -bxe_chip_cleanup(sc, unload_mode, keep_link);
> +if (!sc->grcdump_done)
> +bxe_chip_cleanup(sc, unload_mode, keep_link);
>  } else {
>  /* Send the UNLOAD_REQUEST to the MCP */
>  bxe_send_unload_req(sc, unload_mode);
> @@ -16276,6 +16279,12 @@ bxe_add_sysctls(struct bxe_softc *sc)
>  CTLFLAG_RW, >debug,
>  "debug logging mode");
>
> +sc->trigger_grcdump = 0;
> +SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "trigger_grcdump",
> +CTLFLAG_RW, >trigger_grcdump, 0,
> +"set by driver when a grcdump is needed");
> +
> +
>  sc->rx_budget = bxe_rx_budget;
>  SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "rx_budget",
>  CTLFLAG_RW, >rx_budget, 0,
> @@ -16404,8 +16413,20 @@ bxe_attach(device_t dev)
>  return (ENXIO);
>  }
>
> +if (bxe_add_cdev(sc) != 0) {
> +if (sc->ifp != NULL) {
> +ether_ifdetach(sc->ifp);
> +}
> +ifmedia_removeall(>ifmedia);
> +bxe_release_mutexes(sc);
> +bxe_deallocate_bars(sc);
> +pci_disable_busmaster(dev);
> +return (ENXIO);
> +}
> +
>  /* allocate device interrupts */
>  if (bxe_interrupt_alloc(sc) != 0) {
> +bxe_del_cdev(sc);
>  if (sc->ifp != NULL) {
>  ether_ifdetach(sc->ifp);
>  }
> @@ -16419,6 +16440,7 @@ bxe_attach(device_t dev)
>  /* allocate ilt */
>  if (bxe_alloc_ilt_mem(sc) != 0) {
>  bxe_interrupt_free(sc);
> +bxe_del_cdev(sc);
>  if (sc->ifp != NULL) {
>  ether_ifdetach(sc->ifp);
>  }
> @@ -16433,6 +16455,7 @@ bxe_attach(device_t dev)
>  if (bxe_alloc_hsi_mem(sc) != 0) {
>  bxe_free_ilt_mem(sc);
>  bxe_interrupt_free(sc);
> +bxe_del_cdev(sc);
>  if (sc->ifp != NULL) {
>  ether_ifdetach(sc->ifp);
>  }
> @@ -16504,6 +16527,8 @@ bxe_detach(device_t dev)
>  return(EBUSY);
>  }
>
> +bxe_del_cdev(sc);
> +
>  /* stop the periodic callout */
>  bxe_periodic_stop(sc);
>
> @@ -18824,3 +18849,457 @@ ecore_storm_memset_struct(struct bxe_sof
>  }
>  }
>
> +
> +/*
> + * character device - ioctl interface definitions
> + */
> +
> +
> +#include "bxe_dump.h"
> +#include "bxe_ioctl.h"
> +#include 
> +
> +static int bxe_eioctl(struct cdev *dev, u_long cmd, caddr_t data, int
> fflag,
> +struct thread *td);
> +
> +static struct cdevsw bxe_cdevsw = {
> +.d_version = D_VERSION,
> +.d_ioctl = bxe_eioctl,
> +.d_name = "bxecnic",
> +};
> +
> +#define BXE_PATH(sc)(CHIP_IS_E1x(sc) ? 0 : (sc->pcie_func & 1))
> +
> +
> +#define DUMP_ALL_PRESETS0x1FFF
> +#define DUMP_MAX_PRESETS13
> +#define IS_E1_REG(chips)((chips & DUMP_CHIP_E1) == DUMP_CHIP_E1)
> +#define IS_E1H_REG(chips)   ((chips & DUMP_CHIP_E1H) == DUMP_CHIP_E1H)
> +#define IS_E2_REG(chips)((chips & DUMP_CHIP_E2) == DUMP_CHIP_E2)
> +#define IS_E3A0_REG(chips)  ((chips & DUMP_CHIP_E3A0) ==
> DUMP_CHIP_E3A0)
> +#define IS_E3B0_REG(chips)  

svn commit: r292639 - head/sys/dev/bxe

2015-12-22 Thread David C Somayajulu
Author: davidcs
Date: Wed Dec 23 03:19:12 2015
New Revision: 292639
URL: https://svnweb.freebsd.org/changeset/base/292639

Log:
  Add support for firmware dump (a.k.a grcdump)
  
  MFC after:5 days

Added:
  head/sys/dev/bxe/bxe_dump.h   (contents, props changed)
  head/sys/dev/bxe/bxe_ioctl.h   (contents, props changed)
Modified:
  head/sys/dev/bxe/bxe.c
  head/sys/dev/bxe/bxe.h
  head/sys/dev/bxe/ecore_init.h

Modified: head/sys/dev/bxe/bxe.c
==
--- head/sys/dev/bxe/bxe.c  Wed Dec 23 01:31:32 2015(r292638)
+++ head/sys/dev/bxe/bxe.c  Wed Dec 23 03:19:12 2015(r292639)
@@ -736,6 +736,8 @@ static __noinline int bxe_nic_unload(str
 static void bxe_handle_sp_tq(void *context, int pending);
 static void bxe_handle_fp_tq(void *context, int pending);
 
+static int bxe_add_cdev(struct bxe_softc *sc);
+static void bxe_del_cdev(struct bxe_softc *sc);
 
 /* calculate crc32 on a buffer (NOTE: crc32_length MUST be aligned to 8) */
 uint32_t
@@ -4503,7 +4505,7 @@ bxe_nic_unload(struct bxe_softc *sc,
 sc->rx_mode = BXE_RX_MODE_NONE;
 /* XXX set rx mode ??? */
 
-if (IS_PF(sc)) {
+if (IS_PF(sc) && !sc->grcdump_done) {
 /* set ALWAYS_ALIVE bit in shmem */
 sc->fw_drv_pulse_wr_seq |= DRV_PULSE_ALWAYS_ALIVE;
 
@@ -4523,7 +4525,8 @@ bxe_nic_unload(struct bxe_softc *sc,
 ; /* bxe_vfpf_close_vf(sc); */
 } else if (unload_mode != UNLOAD_RECOVERY) {
 /* if this is a normal/close unload need to clean up chip */
-bxe_chip_cleanup(sc, unload_mode, keep_link);
+if (!sc->grcdump_done)
+bxe_chip_cleanup(sc, unload_mode, keep_link);
 } else {
 /* Send the UNLOAD_REQUEST to the MCP */
 bxe_send_unload_req(sc, unload_mode);
@@ -16276,6 +16279,12 @@ bxe_add_sysctls(struct bxe_softc *sc)
 CTLFLAG_RW, >debug,
 "debug logging mode");
 
+sc->trigger_grcdump = 0;
+SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "trigger_grcdump",
+CTLFLAG_RW, >trigger_grcdump, 0,
+"set by driver when a grcdump is needed");
+
+
 sc->rx_budget = bxe_rx_budget;
 SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "rx_budget",
 CTLFLAG_RW, >rx_budget, 0,
@@ -16404,8 +16413,20 @@ bxe_attach(device_t dev)
 return (ENXIO);
 }
 
+if (bxe_add_cdev(sc) != 0) {
+if (sc->ifp != NULL) {
+ether_ifdetach(sc->ifp);
+}
+ifmedia_removeall(>ifmedia);
+bxe_release_mutexes(sc);
+bxe_deallocate_bars(sc);
+pci_disable_busmaster(dev);
+return (ENXIO);
+}
+
 /* allocate device interrupts */
 if (bxe_interrupt_alloc(sc) != 0) {
+bxe_del_cdev(sc);
 if (sc->ifp != NULL) {
 ether_ifdetach(sc->ifp);
 }
@@ -16419,6 +16440,7 @@ bxe_attach(device_t dev)
 /* allocate ilt */
 if (bxe_alloc_ilt_mem(sc) != 0) {
 bxe_interrupt_free(sc);
+bxe_del_cdev(sc);
 if (sc->ifp != NULL) {
 ether_ifdetach(sc->ifp);
 }
@@ -16433,6 +16455,7 @@ bxe_attach(device_t dev)
 if (bxe_alloc_hsi_mem(sc) != 0) {
 bxe_free_ilt_mem(sc);
 bxe_interrupt_free(sc);
+bxe_del_cdev(sc);
 if (sc->ifp != NULL) {
 ether_ifdetach(sc->ifp);
 }
@@ -16504,6 +16527,8 @@ bxe_detach(device_t dev)
 return(EBUSY);
 }
 
+bxe_del_cdev(sc);
+
 /* stop the periodic callout */
 bxe_periodic_stop(sc);
 
@@ -18824,3 +18849,457 @@ ecore_storm_memset_struct(struct bxe_sof
 }
 }
 
+
+/*
+ * character device - ioctl interface definitions
+ */
+
+
+#include "bxe_dump.h"
+#include "bxe_ioctl.h"
+#include 
+
+static int bxe_eioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
+struct thread *td);
+
+static struct cdevsw bxe_cdevsw = {
+.d_version = D_VERSION,
+.d_ioctl = bxe_eioctl,
+.d_name = "bxecnic",
+};
+
+#define BXE_PATH(sc)(CHIP_IS_E1x(sc) ? 0 : (sc->pcie_func & 1))
+
+
+#define DUMP_ALL_PRESETS0x1FFF
+#define DUMP_MAX_PRESETS13
+#define IS_E1_REG(chips)((chips & DUMP_CHIP_E1) == DUMP_CHIP_E1)
+#define IS_E1H_REG(chips)   ((chips & DUMP_CHIP_E1H) == DUMP_CHIP_E1H)
+#define IS_E2_REG(chips)((chips & DUMP_CHIP_E2) == DUMP_CHIP_E2)
+#define IS_E3A0_REG(chips)  ((chips & DUMP_CHIP_E3A0) == DUMP_CHIP_E3A0)
+#define IS_E3B0_REG(chips)  ((chips & DUMP_CHIP_E3B0) == DUMP_CHIP_E3B0)
+
+#define IS_REG_IN_PRESET(presets, idx)  \
+((presets & (1 << (idx-1))) == (1 << (idx-1)))
+
+
+static int
+bxe_get_preset_regs_len(struct bxe_softc *sc, uint32_t preset)
+{
+if (CHIP_IS_E1(sc))
+return dump_num_registers[0][preset-1];
+else if (CHIP_IS_E1H(sc))
+return dump_num_registers[1][preset-1];
+else if (CHIP_IS_E2(sc))
+return dump_num_registers[2][preset-1];
+else if