1. Feb 10, 2024
  2. Feb 09, 2024
    • David S. Miller's avatar
      Merge branch 'wan-t7x-fastboot' · 4ec3b4aa
      David S. Miller authored
      
      
      Jinjian Song says:
      
      ====================
      net: wwan: t7xx: Add fastboot interface
      
      Add support for t7xx WWAN device firmware flashing & coredump collection
      using fastboot interface.
      
      Using fastboot protocol command through /dev/wwan0fastboot0 WWAN port to
      support firmware flashing and coredump collection, userspace get device
      mode from /sys/bus/pci/devices/${bdf}/t7xx_mode.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4ec3b4aa
    • Jinjian Song's avatar
      net: wwan: t7xx: Add fastboot WWAN port · 2dac6381
      Jinjian Song authored
      On early detection of wwan device in fastboot mode, driver sets
      up CLDMA0 HW tx/rx queues for raw data transfer and then create
      fastboot port to userspace.
      
      Application can use this port to flash firmware and collect
      core dump by fastboot protocol commands.
      E.g., flash firmware through fastboot port:
       - "download:%08x": write data to memory with the download size.
       - "flash:%s": write the previously downloaded image to the named partition.
       - "reboot": reboot the device.
      
      Link: https://android.googlesource.com/platform/system/core/+/refs/heads/main/fastboot/README.md
      
      
      
      Signed-off-by: default avatarJinjian Song <jinjian.song@fibocom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2dac6381
    • Jinjian Song's avatar
      net: wwan: t7xx: Infrastructure for early port configuration · d27553c1
      Jinjian Song authored
      To support cases such as FW update or Core dump, the t7xx
      device is capable of signaling the host that a special port
      needs to be created before the handshake phase.
      
      Adds the infrastructure required to create the early ports
      which also requires a different configuration of CLDMA queues.
      
      Base on the v5 patch version of follow series:
      'net: wwan: t7xx: fw flashing & coredump support'
      (https://patchwork.kernel.org/project/netdevbpf/patch/3777bb382f4b0395cb594a602c5c79dbab86c9e0.1674307425.git.m.chetan.kumar@linux.intel.com/
      
      )
      
      Signed-off-by: default avatarJinjian Song <jinjian.song@fibocom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d27553c1
    • Jinjian Song's avatar
      net: wwan: t7xx: Add sysfs attribute for device state machine · 409c38d4
      Jinjian Song authored
      
      
      Add support for userspace to get/set the device mode, device's state
      machine changes between (unknown/ready/reset/fastboot).
      
      Get the device state mode:
       - 'cat /sys/bus/pci/devices/${bdf}/t7xx_mode'
      
      Set the device state mode:
       - reset(cold reset): 'echo reset > /sys/bus/pci/devices/${bdf}/t7xx_mode'
       - fastboot: 'echo fastboot_switching > /sys/bus/pci/devices/${bdf}/t7xx_mode'
      Reload driver to get the new device state after setting operation.
      
      Signed-off-by: default avatarJinjian Song <jinjian.song@fibocom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      409c38d4
    • Jinjian Song's avatar
      wwan: core: Add WWAN fastboot port type · e3caf184
      Jinjian Song authored
      
      
      Add a new WWAN port that connects to the device fastboot protocol
      interface.
      
      Signed-off-by: default avatarJinjian Song <jinjian.song@fibocom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e3caf184
    • David S. Miller's avatar
      Merge branch 'netconsole-userdata-append' · 20ad4018
      David S. Miller authored
      
      
      Matthew Wood says:
      
      ====================
      netconsole: Add userdata append support
      
      Add the ability to add custom userdata to every outbound netconsole message
      as a collection of key/value pairs, allowing users to add metadata to every
      netconsole message which can be used for  for tagging, filtering, and
      aggregating log messages.
      
      In a previous patch series the ability to prepend the uname release was
      added towards the goals above. This patch series builds on that
      idea to allow any userdata, keyed by a user provided name, to be
      included in netconsole messages.
      
      If CONFIG_NETCONSOLE_DYNAMIC is enabled an additional userdata
      directory will be presented in the netconsole configfs tree, allowing
      the addition of userdata entries.
      
          /sys/kernel/config/netconsole/
      			<target>/
      				enabled
      				release
      				dev_name
      				local_port
      				remote_port
      				local_ip
      				remote_ip
      				local_mac
      				remote_mac
      				userdata/
      					<key>/
      						value
      					<key>/
      						value
                ...
      
      v1->v2:
       * Updated netconsole_target docs, kdoc is now clean
      v2->v3:
       * Remove inline keyword from to_userdat* functions
       * Break up some lines that exceeded 80 chars
       * Replace typos and remove {} from single line if statement
       * Remove unused variable
      
      Testing for this series is as follows:
      
      Build every patch without CONFIG_NETCONSOLE_DYNAMIC, and also built
      with CONFIG_NETCONSOLE_DYNAMIC enabled for every patch after the config
      option was added
      
      Test Userdata configfs
      
          # Adding userdata
          cd /sys/kernel/config/netconsole/ && mkdir cmdline0 && cd cmdline0
          mkdir userdata/release && echo hotfix1 > userdata/release/value
          preview=$(for f in `ls userdata`; do echo $f=$(cat userdata/$f/value); done)
          [[ "$preview" == $'release=hotfix1' ]] && echo pass || echo fail
          mkdir userdata/testing && echo something > userdata/testing/value
          preview=$(for f in `ls userdata`; do echo $f=$(cat userdata/$f/value); done)
          [[ "$preview" == $'release=hotfix1\ntesting=something' ]] && echo pass || echo fail
          #
          # Removing Userdata
          rmdir userdata/testing
          preview=$(for f in `ls userdata`; do echo $f=$(cat userdata/$f/value); done)
          [[ "$preview" == $'release=hotfix1' ]] && echo pass || echo fail
          rmdir userdata/release
          preview=$(for f in `ls userdata`; do echo $f=$(cat userdata/$f/value); done)
          [[ "$preview" == $'' ]] && echo pass || echo fail
          #
          # Adding userdata key with too large of 6.7.0-rc8-virtme,12,481,17954104,-directory name [<54 chars]
          mkdir userdata/testing12345678901234567890123456789012345678901234567890
          [[ $? == 1 ]] && echo pass || echo fail
          #
          # Adding userdata value with too large of value [<200 chars]
          mkdir userdata/testing
          echo `for i in {1..201};do printf "%s" "v";done` > userdata/testing/value
          [[ $? == 1 ]] && echo pass || echo fail
          rmdir userdata/testing
      
      - Output:
      
          pass
          pass
          pass
          pass
          pass
          mkdir: cannot create directory ‘cmdline0/userdata/testing12345678901234567890123456789012345678901234567890’: File name too long
          pass
          bash: echo: write error: Message too long
          pass
      
      Test netconsole messages (w/ msg fragmentation)
      
          echo `for i in {1..996};do printf "%s" "v";done` > /dev/kmsg
      
      - Output:
      
          6.7.0-rc8-virtme,12,484,84321212,-,ncfrag=0/997;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv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mdline0
          mkdir cmdline0/userdata/empty
          echo test > /dev/kmsg
          rmdir cmdline0/userdata/empty
      
      - Output:
      
      Test netconsole messages (w/o userdata fragmentation)
      
          cd /sys/kernel/config/netconsole/ && mkdir cmdline0
          mkdir cmdline0/userdata/release && echo hotfix1 > cmdline0/userdata/release/value
          mkdir cmdline0/userdata/testing && echo something > cmdline0/userdata/testing/value
          echo test > /dev/kmsg
          rmdir cmdline0/userdata/release
          rmdir cmdline0/userdata/testing
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      20ad4018
    • Matthew Wood's avatar
      net: netconsole: append userdata to fragmented netconsole messages · 1ec9daf9
      Matthew Wood authored
      
      
      Regardless of whether the original message body or formatted userdata
      exceeds the MAX_PRINT_CHUNK, append userdata to the netconsole message
      starting with the first chunk that has available space after writing the
      body.
      
      Co-developed-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarMatthew Wood <thepacketgeek@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1ec9daf9
    • Matthew Wood's avatar
      net: netconsole: append userdata to netconsole messages · b4ab4f2c
      Matthew Wood authored
      
      
      Append userdata to outgoing unfragmented (<1000 bytes) netconsole messages.
      When sending messages the userdata string is already formatted and stored
      in netconsole_target->userdata_complete.
      
      Always write the outgoing message to buf, so userdata can be appended in
      a standard fashion. This is a change from only using buf when the
      release needs to be prepended to the message.
      
      Co-developed-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarMatthew Wood <thepacketgeek@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b4ab4f2c
    • Matthew Wood's avatar
      net: netconsole: cache userdata formatted string in netconsole_target · df03f830
      Matthew Wood authored
      
      
      Store a formatted string for userdata that will be appended to netconsole
      messages. The string has a capacity of 4KB, as calculated by the userdatum
      entry length of 256 bytes and a max of 16 userdata entries.
      
      Update the stored netconsole_target->userdata_complete string with the new
      formatted userdata values when a userdatum is created, edited, or
      removed. Each userdata entry contains a trailing newline, which will be
      formatted as such in netconsole messages::
      
          6.7.0-rc8-virtme,12,500,1646292204,-;test
          release=foo
          something=bar
          6.7.0-rc8-virtme,12,500,1646292204,-;another test
          release=foo
          something=bar
      
      Enforcement of MAX_USERDATA_ITEMS is done in userdatum_make_item;
      update_userdata will not check for this case but will skip any userdata
      children over the limit of MAX_USERDATA_ITEMs.
      
      If a userdata entry/dir is created but no value is provided, that entry
      will be skipped. This is in part because update_userdata() can't be
      called in userdatum_make_item() since the item will not have been added
      to the userdata config_group children yet. To preserve the experience of
      adding an empty userdata that doesn't show up in the netconsole
      messages, purposefully skip empty userdata items even when
      update_userdata() can be called.
      
      Co-developed-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarMatthew Wood <thepacketgeek@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      df03f830
    • Matthew Wood's avatar
      net: netconsole: add a userdata config_group member to netconsole_target · 8a6d5fec
      Matthew Wood authored
      
      
      Create configfs machinery for netconsole userdata appending, which depends
      on CONFIG_NETCONSOLE_DYNAMIC (for configfs interface). Add a userdata
      config_group to netconsole_target for managing userdata entries as a tree
      under the netconsole configfs subsystem. Directory names created under the
      userdata directory become userdatum keys; the userdatum value is the
      content of the value file.
      
      Include the minimum-viable-changes for userdata configfs config_group.
      init_target_config_group() ties in the complete configfs machinery to
      avoid unused func/variable errors during build. Initializing the
      netconsole_target->group is moved to init_target_config_group, which
      will also init and add the userdata config_group.
      
      Each userdatum entry has a limit of 256 bytes (54 for
      the key/directory, 200 for the value, and 2 for '=' and '\n'
      characters), which is enforced by the configfs functions for updating
      the userdata config_group.
      
      When a new netconsole_target is created, initialize the userdata
      config_group and add it as a default group for netconsole_target
      config_group, allowing the userdata configfs sub-tree to be presented
      in the netconsole configfs tree under the userdata directory.
      
      Co-developed-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarMatthew Wood <thepacketgeek@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8a6d5fec
    • Matthew Wood's avatar
      net: netconsole: add docs for appending netconsole user data · aa7b608d
      Matthew Wood authored
      
      
      Add a new User Data section to the netconsole docs to describe the
      appending of user data capability (for netconsole dynamic configuration)
      with usage and netconsole output examples.
      
      Co-developed-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
      Signed-off-by: default avatarMatthew Wood <thepacketgeek@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      aa7b608d