GithubHelp home page GithubHelp logo

bluecmd / fejkon Goto Github PK

View Code? Open in Web Editor NEW
35.0 7.0 2.0 3.75 MB

Fibre Channel / FICON HBA implemented on FPGA

License: GNU General Public License v3.0

Makefile 1.83% Tcl 47.72% SystemVerilog 19.28% Verilog 11.57% Go 1.11% C 6.29% Shell 0.12% Stata 4.30% Python 5.76% C++ 2.02%

fejkon's Introduction

fejkon

Status: Sleeping (#72).

fejkon is a basic host bus adapter (HBA) for Fibre Channel (and thus, FICON) implemented on the DE5-Net board. The aim is to provide easy access to add or consume Fibre Channel services, such as FCP or FICON from an ordinary server.

DE5-Net running Fejkon

Fejkon, which was born out of the need for a fake FICON HBA, is a Swedish pun playing on the word "fejk" which translates "fake". It is pronounced similarly to the "FIC" in "FICON".

It is meant to be one of the possible access ports to fikonfarm enabling IBM mainframes to e.g. use Hercules disks natively.

In the past there existed a commerical product called FLEXCUB that seems to have done something similar for ESCON.

Design

The overall system design is as shown below. Using quad SFP+ ports Fejkon is configured to communicate using 8GFC (no speed negotiation will be implemented).

8G Fibre Channel

 +-----------+
 | FC Port 0 +<-------------------------------+
 +-----+-----+                                |
       ^                                      |
       |  (Optional) Traffic Bridging         |
       v                                      |
 +-----+-----+                                |
 | FC Port 1 +<--------+                      v
 +-----------+         |        +-------------+--------------+
                       +------->+                            |        +----------------+
 +-----------+                  |                            |        |                |
 | FC Port 2 +<---------------->+       Packet Stream        +<------>+  PCIe 3.0 x8   |
 +-----------+                  |   Input/Output Mux/Demux   |        |                |
                       +------->+                            |        +----------------+
 +-----------+         |        |                            |
 | FC Port 3 +<--------+        +----------------------------+
 +-----------+

Board

Target board right now is the DE5-Net from Terasic. They are available for $300 - $600 on eBay as of this writing and are capable of implementing 4x 8 Gbit/s Fibre Channel ports on a PCIe Gen 3 x8 port.

There are a few modifications to the board that are recommended.

  • Remove DDR3 SODIMMs, they are not needed and contribute to power drain
  • Add a heatsink onto of the LTM4601V

DE5-Net Voltage Regulators

Configuring and Building

FPGA tooling can be a bit stuborn to work with, and if you do not have an FPGA background you might not want to use them.

Fejkon uses Kconfig menu configuration for configuring the board features, and can be configured and built like this:

$ pip3 install kconfiglib     # Required build dependency
$ make menuconfig             # Optional: Change configuration
$ make

The configuration interface looks like this:

Menuconfig interface

Usage Notes

Hopefully the card is straight forward to use, but every product needs a manual. This is it.

Port Status

The leds on the front of the card next to the RJ45 port signals when the port is considered active. This means for FC that the port state machine has entered the ACTIVE state.

The leds next to the four switches on the board indicate if the transmit laser is activated.

The leds next to the SFP cages indicate whether or not an SFP module is detected in that slot.

Cooling

The fan is configured to only turn on when the temperature reaches 60°C. If that happens the fan will remain on until the board has been reset.

Wireshark / tcpdump

libpcap defaults to DLT_FC2 which does not account for SOF/EOF which are included in fejkon - so you need to tell it that those are included.

Example:

tshark -i fc0 -y FC_2_WITH_FRAME_DELIMS

MSI Interrupts

Currently fejkon is using multiple MSI interrupts, not MSI-X. MSI-X is a bit more complicated to implement, and the benefits of MSI-X over MSI isn't very documented when you don't need the thousands interrupts that MSI-X offers.

During development it was discovered that e.g. QEMU does not do multiple MSI interrupts by default, and some kernel options are needed as well. The symptom of the platform not being setup correctly is that pci_alloc_irq_vectors(pcidev, 1, irqs, PCI_IRQ_ALL_TYPES); only returns one available vector instead of the requested number. There appears to be other people that have ran into the same issue. In the kernel this support for multiple MSI interrupts seems to be gated by MSI_FLAG_MULTI_PCI_MSI.

To enable the kernel support, enable CONFIG_IRQ_REMAP. On Intel, you should see mentions of DMAR in your dmesg. This is usually enabled by enabling VT-d. The equivalent on AMD seems to be just IOMMU support, but that has not been verified. PCIe hotplug has been known to cause issues, so you might want to disable that.

The configuration for QEMU is something like:

-machine q35,kernel-irqchip=split \
-device intel-iommu,intremap=on,device-iotlb=on \

Since the card only uses MSI interrupts, legacy interrupts are disabled.

So if you are designing something from scratch and have the option to use MSI or MSI-X, this information above should tell you that maybe using MSI-X will be easier. However, it is quite likely MSI-X has its own pitfalls.

SFP Diagnostics Data

Fejkon exposes the I2C interfaces through the Linux kernel's native I2C interface. This means that accessing the SFP diagnostics data is possible using any standard I2C library.

The recommended way to browse SFP data is using Safaripark, but there is also a simple CLI tool located in driver/cmd/fejkon-sfp.

Safaripark screenshot

Developing

The recommended flow is using Quartus Platform Designer to make changes.

To build the qsys files needed simply execute make QPATH=/path/to/quartus in the root directory. Then use platform designer to edit fejkon.qsys using make edit-clean. When you are done, export the system using "Export System as Platform Designer script (.tcl)" under the "File" menu. If you have updated any subsystems you need to this for those systems as well.

Finally review any changes to the *.tcl files and commit them if they look reasonable.

To run the tests first install the dependencies:

# NOTE: You need Icarus Verilog 11.0 or newer, or always_* constructs will
# not be accepted.
$ sudo apt install iverilog gtkwave verilator
$ sudo apt install python3-pip
$ pip3 install cocotb

Then to execute all tests run:

$ make -j test

NOTE: The driver tests are located under driver and are not automatically run.

PCIe specification

The board uses vendor/device ID f1c0:0de5. Mnemonic is FICOn DE5-net.

The PCIe endpoint has one Base Address Register (BAR).


                                          Avalon-St               Avalon-MM
                                   +-------------------+      +---------------->   BAR 0
                                   |                   |      |
                                   |                   v      |
                                   |           +-------+------+--------+
                                   |           |                       |
                                   |           |   Fejkon PCIe Data    +<------+   Packet Data DMA
                                +--+--+        |       Facility        +------->   TX/RX Avalon-St
                                |     |        |                       |
                                |  A  |        +---+-------+-------+---+
                                |     |            |       |       |
                                |  D  |            v       v       v
+----------------------+        |     |         +--+--+-+--+--+-+--+--+
|                      |        |  A  |         |     | |     | |     |
|                      +------->+     |         |  F  | |  F  | |  F  |     3 TLP streams:
|    Intel PCIe Core   |        |  P  |         |  I  | |  I  | |  I  |     * Packet Data (DMA)
|                      +<-------+     |         |  F  | |  F  | |  F  |     * Failed Completions
|                      |        |  T  |         |  O  | |  O  | |  O  |     * Successful Completions
+----------+-----------+        |     |         |     | |     | |     |
           ^                    |  E  |         +--+--+ +--+--+ +--+--+
           |                    |     |            |       |       |
           v                    |  R  |            v       v       v
                                |     |         +--+-------+-------+--+
      PCIe 3.0 x8               +--+--+         |                     |
                                   ^            |     Stream Mux      |
                                   |            |                     |
                                   |            +----------+----------+
                                   |                       |
                                   |       Avalon-St       |
                                   +-----------------------+

The design uses components from Quartus Platform Design to minimize development and debug time. All FPGA platforms offer some sort of FIFOs and streaming interface that allows merging, so there is little value re-inventing those.

The PCIe adapter is a bug-fix for the V-Series Intel PCIe core where the streaming interface is not correctly defined to be Avalon-ST compliant. See the section about Intel PCIe TLP adapter below for details.

BAR 0

Accesses need to be 4 byte wide.

Addr Width Part Name Description
0x0000 2 Card Version The constant 0x0DE5
0x0002 1 Card Version Version of the Fejkon card
0x0003 1 Card Port options Number of ports
0x0004 4 Card Git hash Git hash of HDL built
0x0010 1 Card Temprature FPGA Core Temperature (1)
0x0020 4 Card Freq. Gauge PHY effective clock gauge
0x0024 4 Card Freq. Gauge PCIe effective clock gauge
0x0040 64 Card FC Dbg & Gen Inspect / Inject point
0x0100 1 Port 0 SFP Status SFP Status Word (3)
0x0140 64 Port 0 SFP Port I2C SFP I2C core (4)
0x02x0 ... Port 1 SFP Port
0x03x0 ... Port 2 SFP Port
0x04x0 ... Port 3 SFP Port
0x0800 1024 Card PCIe Facility PCIe counters and status (2)
0x8000 2048 Port 0 FC XCVR IP Fejkon FC XCVR Core (5)
0x8800 2048 Port 0 TX XCVR Mgmt V-Series Transceiver PHY (6)
0x9000 64 Port 0 FC Framer Fibre Channel Framer (7)
0x9100 8 Port 0 PCIe CDC FIFO (Undoc.) fc0_rx_cdc
0xAxxx ... Port 1 ...
0xCxxx ... Port 2 ...
0xExxx ... Port 3 ...
0xFE00 512 Card XCVR Reconfig (Undoc.) xcvr_reconfig
  1. Details in section below
  2. Details in section below
  3. Details in section below
  4. See "Intel FPGA Avalon I2C (Master) Core" in Embedded Peripherals IP User Guide
  5. Details in section below
  6. See "Custom PHY" in V-Series Transceiver PHY IP Core User Guide
  7. Details in section below

PCIe Facility

Addr Width Name
0x000 2 Endpoint address
0x002 2 Internal status
0x004 4 RX TLP counter
0x008 4 RX Unsupported TLP counter
0x00C 4 TX Data TLP counter
0x010 4 TX Instant TLP counter
0x014 4 TX Response TLP counter
0x018 4 C2H Staging Packets counter
0x020 32 Last RX TLP (8 DWs)
0x040 32 Last TX Data TLP (8 DWs)
0x060 32 Last TX Instant TLP (8 DWs)
0x080 32 Last TX Response TLP (8 DWs)
0x0A0 4 C2H DMA buffer start address
0x0A4 4 C2H DMA buffer end address
0x0A8 4 C2H DMA host read pointer
0x0AC 4 C2H DMA card write pointer
0x0C0 4 H2C DMA buffer start address
0x0C4 4 H2C DMA buffer end address
0x0C8 4 H2C DMA card read pointer
0x0CC 4 H2C DMA host write pointer
0x100 4 Data TX TLP Fill Level
0x110 4 Instant TX TLP Fill Level
0x120 4 Response TX TLP Fill Level
0x180 4 LTSSM and lane active mode

Temperature

See Temperature decoding details in FPGA Temperature Sensor IP Core User Guide

Bit(s) Direction Description
7:0 Read only A/D conv. value
8 Read only A/D complete

SFP Port Status

Bit(s) Direction Description
0 Read only Present
1 Read only Loss of Signal
2 Read only TX Fault
3 Read/Write TX Disable
4:5 Read/Write Rate Select
6 Read/Write I2C Reset

Fejkon FC XCVR Core

Addr Width Name
0x00000 4 Port Status
0x00004 4 Last Unknown Coded Set
0x00080 128 RX Primitive Counters
0x00100 128 TX Primitive Counters

The primitive counters logged are in order:

  • IDLE
  • R_RDY
  • VC_RDY
  • BB_SCS
  • BB_SCR
  • SOFi2
  • SOFn2
  • SOFi3
  • SOFn3
  • SOFf
  • EOFt
  • EOFa
  • EOFn
  • EOFni
  • NOS
  • OLS
  • LR
  • LRR
  • ARBff
  • Unknown

The data type is unsigned 32 bit integer for the primitive counters.

Port Status
Bit(s) Description Values
0:3 Sync Status 0xf = fully synced
4:7 Pattern detect 0x1 = detected
8:11 Error detect >0 = error(s) detected
12:15 Disparity error >0 = error(s) detected
16 PLL Locked 1 = PLL locked

A fully operational port has status 0x1001f.

FC Framer

Note that internally the address space is split up so that the lower half contains registers related to receive and upper half is related to transmit.

Addr Width Name
0x000 4 State
0x004 4 # of ACTIVE state transitions
0x008 4 # of FC frames received

States:

Value Code Name
0 AC Active
1 LR1 LR Transmit
2 LR2 LR Receive
3 LR3 LRR Receive
4 LF1 NOS Receive
5 LF2 NOS Transmit
6 OL1 OLS Transmit
7 OL2 OLS Receive
8 OL3 Wait for OLS

Note: Only ACTIVE is guaranted to be stable at numeric 0 over time.

FC Debug & Generator

This component is used to generate traffic for debug and development. It generates traffic interleaved with the output of the FC subsystem, and its output is read by both the PCIe and the future Ethernet module.

Addr Width Name
0x000 4 Packet inject counter

Interrupts

Vector Description
0 Card status
1 RX Data available
2 RX Packet dropped
3-6 Port 0/1/2/3 SFP I2C

Debugging

Use make syscon to launch Intel's System Console. It will guide you through the debug commands, but here is an example of reading the SFP data from port 1:

=> Fejkon system console initialized

 Master is available at $m

 E.g:
 - master_write_32 $m 0x000e0000 5
 - jtag_debug_reset_system $m
 - sfp 1

% sfp 1
 SFP status: 0x02
 SFP identifier: 0x03
 SFP ext. identifier: 0x04
 SFP connector: 0x07
 SFP vendor: 'JDS UNIPHASE    '
 SFP vendor PN: 'JSM-21S0AA1     '
 SFP vendor SN: 'F44939581059    '

The design has been compiled with instrumentation of some key data buses which you can inspect using make syscon by loading the fejkon.sof and using "Bus Analyzer (Beta)".

If you need to debug a particular component, then using Signal Tap is recommended.

PCIe

Look at the pcie syscon command to get more information. If the My ID row reads all zeroes that means the host PC has rejected the card for whatever reason.

Known Issues / Notes

Si570

The Si570 on board appears to have the following specs:

Part Number: 570FAB000433DG
Product: Si570
Description: Differential/single-ended; I2C programmable XO; 10-1417 MHz
Frequency A: 100 MHz
I2C Address (Hex Format): 0
Format: LVDS
Supply Voltage: 2.5 V
OE Polarity: OE active high
Temperature Stability / Total Stability: 50 ppm / 61.5 ppm
Frequency Range: 10 - 810 MHz
Operating Temp Range (°C): -40 to +85

Usage under WSL and ChromeOS Crostini

There are some known issues for running under Windows Subsystem for Linux (WSL) and ChromeOS Crostini (external reports).

realloc(): invalid pointer

This seems to happen on Ubuntu 18.04 and newer, including 20.04 LTS. When starting Quartus or some other tools they will crash with the following error message:

$ ~/intelFPGA/20.1/quartus/bin/quartus
realloc(): invalid pointer
zsh: abort (core dumped)  ~/intelFPGA/20.1/quartus/bin/quartus

This can be worked around by pre-loading the system's udev version. Exact reason why this workaround works is not known.

$ export LD_PRELOAD=/lib/x86_64-linux-gnu/libudev.so.1

This has been reported to Intel.

Macro <protected> is undefined

This is known to happen if you apply the above LD_PRELOAD fix and then launch ModelSim compilation. The bug can be triggered on normal machines as well if you accidentally applied the LD_PRELOAD hack to them.

For some reason ModelSim then fails to decrypt the encrypted device libraries when told to preload a library. Note: It does not have to be udev, this has been known to fail for other preloades e.g. in /etc/ld.so.preload.

# ** Error: ../intelFPGA/20.1/quartus/eda/sim_lib/mentor/stratixv_atoms_ncrypt.v(38): (vlog-2163) Macro `<protected> is undefined.
# ** Error: ../intelFPGA/20.1/quartus/eda/sim_lib/mentor/stratixv_atoms_ncrypt.v(38): (vlog-2163) Macro `<protected> is undefined.
# ** Error: (vlog-13069) ../intelFPGA/20.1/quartus/eda/sim_lib/mentor/stratixv_atoms_ncrypt.v(38): syntax error in protected region.
#
# ** Error: ../intelFPGA/20.1/quartus/eda/sim_lib/mentor/stratixv_atoms_ncrypt.v(38): (vlog-13205) Syntax error found in the scope following '<protected>'. Is there a missing '::'?
# End time: 23:08:09 on Aug 20,2020, Elapsed time: 0:00:00
# Errors: 5, Warnings: 0

This can be worked around by making sure you do not set LD_PRELOAD before running vsim (or unset LD_PRELOAD) and making sure /etc/ld.so.preload does not exist.

Intel PCIe TLP adapter

The Avalon-ST interface from the PCIe IP is not standard compliant.

Avalon-ST has a property called firstSymbolInHighOrderBits which is supposed to be set to true when the first symbol is present in e.g. data[255:224].

The PCIe IP for Qsys uses the lower bits for first symbol, but unfortunately chose to set firstSymbolInHighOrderBits to true.

Furthermore, the empty signal is not compliant either.

These issues are managed by the intel_pcie_tlp_adapter to make the design and testbenches being able to use Avalon-ST correctly.

Possible future work

  • Integrate the MAX1619 sensor

The MAX1619 is an SMBus temperature sensor supported by the Linux kernel. It would allow for more temperature data. However, SMBus seems to be incompatible with the Intel I2C core, and no replacement core seems to be easily avaiable. This means writing an SMBus controller, QEMU model, Linux and driver for it.

An alternative is to re-use Terasic's NIOS drivers and create an enviromental processor that controls not only the temperature sensor but also the fan. However, this breaks the "keep it simple" methodology currently in use.

  • Over-temperature auto-shutdown

The Intel FPGAs do not feature a protective auto-shutdown as Xilinx FPGAs do. It would be useful to enter some kind of low-power mode if an over-temperature condition is detected.

Possibly integrated with the above work.

  • Replace Si570 with soft core CPU

Although writing the Si570 controller was useful, in the end it is less reliable and much more expensive, than using a soft core to implement the equivalent logic. Using a soft core like NIOS, RISC-V, or OpenRISC would make it possible to control clock and reset networks from the firmware of the card instead of wiring it up in Verilog. In the beginning I thought this would end up being simpler, and while it ended up being a very good learning experience if I had to do it again I would stick a soft core CPU on there and let it do temperature, fan, reset, and clock control.

fejkon's People

Contributors

bluecmd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fejkon's Issues

Brocade Loopback and E-port notes

This is a bug/feature-request/documentation issues for documenting what is know about Brocade Loopback and E-port behaviour.

Quest

This is a side-quest for acquiring more knowledge. No feature currently depends on this. It would be cool to understand how this is implemented by Brocade to deepen the understanding of real-world FC equipment.

Status

Observed behavior is that the port links up to AC state just fine, but is then sent a Link Reset (LR) at which point the idle-word seems to switch to ARB(AL_PA) with AL_PA=0xEF.

What needs to be done?

  • Map the 8b/10b traffic that is sent between two different Brocade switches (E-ports)
# TODO: No port status dump for this
  • Map the 8b/10b traffic that is sent between a loopback on a Brocade switch. (Loopback)
Index Port Address Media Speed       State   Proto
==================================================
  27  27   010000   id    8G	   Online      FC  Loopback->Port 31 
  31  31   010100   id    8G	   Online      FC  Loopback->Port 27
  • Map the 8b/10b traffic that is sent between two virtual switches on a single Brocade switch. (
  27  27   010000   id    8G	   Online      FC  E-Port  segmented,10:00:00:05:1e:eb:e1:80 (ESC mismatch, Fabric ID)(Trunk master)  

Extra questions

  • What is this ESC missmatch Fabirc Id message about? Is it because we are linking up the same switch to itself? Try with another switch to figure out maybe.

FC framer loopback mode

Right now the loop-mode between port 1-2 does not work as well as it should.

When connecting two ports together on a Brocade switch it should say:

  27  27   011b00   id    8G	   Online      FC  Loopback->Port 31 
[..]
  31  31   011f00   id    8G	   Online      FC  Loopback->Port 27 

Right now it says:

  27  27   011b00   id    8G	   Online      FC  E-Port  (unknown)
[..]
  31  31   011f00   id    8G	   Online      FC  G-Port  

Discussion about initial PSM state

The protocol state machine is defined with these edge states:

  • Link Initialization OL1 7.8.2
  • Link Reset LR1 7.8.3
  • Link Failure LF2 7.8.4
  • Online-to-Offline OL1 7.8.5

The standard says:

7.8.2 Link Initialization Protocol

The Link Initialization Protocol shall be performed by an LCF after one of the following events has
occurred:

a) powered-on;
b) internal reset (the definition of internal reset is beyond the scope of this standard); or
c) has been offline and desires to come back online.

The Link Initialization Protocol begins when the LCF enters the OL1 State after one of the above events has been detected and is complete when the LCF enters the Active State.

The Link Initialization Protocol results in implicit Fabric Logout (see FC-LS-4).

7.8.3 Link Reset Protocol

The Link Reset Protocol shall be performed when any of the following conditions are detected:

a) link timeout (see 22.5.2); or
b) buffer-to-buffer overrun (i.e., an FC_Port receives a frame subject to buffer-to-buffer flow control without a buffer available).

The Link Reset Protocol begins when the FC_Port enters the LR1 State after one of the above events has
been detected and is complete when the FC_Port enters the Active State.

7.8.4 Link Failure Protocol

The Link Failure Protocol shall be performed after an FC_Port has detected one of the following
conditions:

a) a Loss-of-Synchronization for a period of time greater than R_T_TOV;
b) Loss-of-Signal while not in the Offline State; or
c) Link Reset Protocol timeout error is detected (see 7.8.3).

The Link Failure Protocol begins when the FC_Port enters the LF2 State after one of the above events has
been detected and is complete when the Active State is entered.

Vocabulary:

  • Link Control Facility (LCF) - hardware facility that attaches to an end of a link and manages transmission and reception of data

FC framer in passive RX mode

Implement a mode where the FC framer can be told to operate only on RX and ignore the state machine.

This is useful for use with passive TAPs

FC Data corrupt?

There seems to be some odd things going on with the FC data.

This is one of the frames from the C2H DMA:

Fibre Channel Delimiter: SOF: SOFf - SOF Fabric EOF: 0x0
    SOF: SOFf - SOF Fabric (0xbcb55858)
    CRC: 0x00000000 incorrect, should be 0x9b466380
        [Expert Info (Error/Checksum): Bad checksum [should be 0x9b466380]]
            [Bad checksum [should be 0x9b466380]]
            [Severity level: Error]
            [Group: Checksum]
    [CRC Status: Bad]
    EOF: Unknown (0x00000000)
Fibre Channel
    R_CTL: 0x7(Device_Data/Command Status)
    Dest Addr: 9f.7a.fd
    CS_CTL: 0x7c
    Src Addr: 6c.0f.09
    Type: Unknown (0x3f)
    F_CTL: 0x0f6741, ExgRpd: Exchange Originator, SeqRec: Seq Initiator, ExgFst: NOT exchg first, ExgLst: NOT exchg last, SeqLst: Seq Last, Pri: Priority, TSI: Transfer Seq Initiative, LDF: Unknown, A01: Unknown, RetSeq: Retransmitted Sequence
        0... .... .... .... .... .... = ExgRpd: Exchange Originator
        .0.. .... .... .... .... .... = SeqRec: Seq Initiator
        ..0. .... .... .... .... .... = ExgFst: NOT exchg first
        ...0 .... .... .... .... .... = ExgLst: NOT exchg last
        .... 1... .... .... .... .... = SeqLst: Seq Last
        .... ..1. .... .... .... .... = Pri: Priority
        .... ...1 .... .... .... .... = TSI: Transfer Seq Initiative
        .... .... 01.. .... .... .... = LDF: Unknown (0x1)
        .... .... ..10 .... .... .... = A01: Unknown (0x2)
        .... .... .... ..1. .... .... = RetSeq: Retransmitted Sequence
        .... .... .... .... ..00 .... = AA: ABTS - Cont (0x0)
        .... .... .... .... .... 0... = RelOff: rel offset NOT set
    SEQ_ID: 0x1a
    DF_CTL: 0x7d
    SEQ_CNT: 56449
    OX_ID: 0x41f9
    RX_ID: 0xd400
    Parameter: 0x9df4d3f8
    Network DA: 6f:4e:e9:80:8f:ea:63:c8
    Network SA: d2:a5:93:f4:6b:3d:be:c3
Data (2504 bytes)
    Data: 61a98662574702abbecf16959856d5bd18f508cd6f848d17…
    [Length: 2504]

0000  bc b5 58 58 07 9f 7a fd 7c 6c 0f 09 3f 0f 67 41   ..XX..z.|l..?.gA
0010  1a 7d dc 81 41 f9 d4 00 9d f4 d3 f8 6f 4e e9 80   .}..A.......oN..
0020  8f ea 63 c8 d2 a5 93 f4 6b 3d be c3 61 a9 86 62   ..c.....k=..a..b
0030  57 47 02 ab be cf 16 95 98 56 d5 bd 18 f5 08 cd   WG.......V......
0040  6f 84 8d 17 a7 9c 3a 40 ce 6d 7d 9d 66 92 4a c8   o.....:@.m}.f.J.
0050  29 92 4b 8c bc c1 9e dd 7d eb 60 12 8a 9c 61 9f   ).K.....}.`...a.
0060  5f cd 3c 61 99 a7 fd af 30 7c 57 9d 37 9b 92 43   _.<a....0|W.7..C
0070  25 7a d0 4b 60 ae 65 6f ca 76 4b 12 f4 0d b7 64   %z.K`.eo.vK....d
0080  b8 7a db d3 c8 1d 2c 99 b9 26 ce ab 34 39 6b e3   .z....,..&..49k.
0090  1f db d8 1e c8 65 4f 77 34 66 cd 2c f7 3b 10 57   .....eOw4f.,.;.W
00a0  40 5d 3d 1d 60 44 af aa d2 8f ce 07 44 8e f5 28   @]=.`D......D..(
00b0  ad 7a 9c 39 72 e7 bf 10 2c 42 c1 22 99 b7 41 89   .z.9r...,B."..A.
00c0  55 83 26 27 7f 7b 64 1a 2e 37 7f 17 ea 85 68 75   U.&'.{d..7....hu
00d0  a2 0a cf 28 4a 1e 08 f5 d2 27 f6 03 6c 26 72 98   ...(J....'..l&r.
00e0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
00f0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0100  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0110  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................

The SOF marker is clearly present, and it is in the correct place - so I wonder what the other data is.
This could be something special that SOFf frames do as well that I need to read up on.

The frames are really huge as well, increasing by 404 bytes every time.

The first packet that is sent to the C2H is:

Fibre Channel Delimiter: SOF: 0xbc94ffff EOF: 0x0
    SOF: Unknown (0xbc94ffff)
    CRC: 0x00000000 incorrect, should be 0xc8c2a7d2
        [Expert Info (Error/Checksum): Bad checksum [should be 0xc8c2a7d2]]
            [Bad checksum [should be 0xc8c2a7d2]]
            [Severity level: Error]
            [Group: Checksum]
    [CRC Status: Bad]
    EOF: Unknown (0x00000000)
Fibre Channel
    R_CTL: 0xbc(0xb0/0xc)
    Dest Addr: 94.ff.ff
    CS_CTL: 0xbc
    Src Addr: 94.ff.ff
    Type: Unknown (0xbc)
    F_CTL: 0x94ffff, ExgRpd: Exchange Responder, SeqRec: Seq Initiator, ExgFst: NOT exchg first, ExgLst: Exchg Last, SeqLst: NOT seq last, Pri: CS_CTL, TSI: NOT transfer seq initiative, LDF: Unknown, A01: Unknown, RetSeq: Retransmitted Sequenc
        1... .... .... .... .... .... = ExgRpd: Exchange Responder
        .0.. .... .... .... .... .... = SeqRec: Seq Initiator
        ..0. .... .... .... .... .... = ExgFst: NOT exchg first
        ...1 .... .... .... .... .... = ExgLst: Exchg Last
        .... 0... .... .... .... .... = SeqLst: NOT seq last
        .... ..0. .... .... .... .... = Pri: CS_CTL
        .... ...0 .... .... .... .... = TSI: NOT transfer seq initiative
        .... .... 11.. .... .... .... = LDF: Unknown (0x3)
        .... .... ..11 .... .... .... = A01: Unknown (0x3)
        .... .... .... ..1. .... .... = RetSeq: Retransmitted Sequence
        .... .... .... .... ..11 .... = AA: Unknown (0x3)
        .... .... .... .... .... 1... = RelOff: Rel Offset SET
    SEQ_ID: 0xbc
    DF_CTL: 0x94
    SEQ_CNT: 65535
    OX_ID: 0xbc94
    RX_ID: 0xffff
    Parameter: 0xbc94ffff
Data (500 bytes)
    Data: bc94ffffbc94ffffbc94ffffbc94ffffbc94ffffbc94ffff…
    [Length: 500]

0000  bc 94 ff ff bc 94 ff ff bc 94 ff ff bc 94 ff ff   ................
0010  bc 94 ff ff bc 94 ff ff bc 94 ff ff bc 94 ff ff   ................
0020  bc 94 ff ff bc 94 ff ff bc 94 ff ff bc 94 ff ff   ................
0030  bc 94 ff ff bc 94 ff ff bc 94 ff ff bc 94 ff ff   ................
0040  bc 94 ff ff bc b5 58 58 07 9f 7a fd 7c 6c 0f 09   ......XX..z.|l..
0050  3f 0f 67 41 07 7d dc 81 41 d8 d4 07 dd f4 91 f8   ?.gA.}..A.......
0060  69 8e e8 d4 8f f7 63 cb ca a5 fc f4 6a 4d be db   i.....c.....jM..
0070  61 b0 a6 62 3b 47 36 eb b8 5f 16 e6 18 56 e5 bc   a..b;G6.._...V..
0080  5b f5 14 4d 6d 0e 8d 7e 67 9e 0e 40 bf 6d 63 85   [[email protected].
0090  66 fd 4a e8 59 95 13 8c e7 e1 98 71 7c 8b 20 09   f.J.Y......q|. .
00a0  1a 9f 0a 1f 30 fd 3c 52 99 a3 7d b4 9a 7c 52 5d   ....0.<R..}..|R]
00b0  01 ef 94 a2 25 17 48 4b 3f af 06 1f d1 ae 49 c3   ....%.HK?.....I.
00c0  d4 62 db 67 ec 3a b1 43 d5 6e ac 99 89 06 8d ac   .b.g.:.C.n......
00d0  68 b9 2b 69 19 72 19 48 fc 78 3e 74 32 7e a2 43   h.+i.r.H.x>t2~.C
00e0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
00f0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0100  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0110  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0120  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0130  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0140  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0150  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0160  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0170  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0180  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0190  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01a0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01b0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01c0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01d0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01e0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01f0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0200  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0210  00 00 00 00 00 00 00 00                           ........

Followed by:

Fibre Channel Delimiter: SOF: SOFf - SOF Fabric EOF: 0x0
    SOF: SOFf - SOF Fabric (0xbcb55858)
    CRC: 0x00000000 incorrect, should be 0xa6752ff1
        [Expert Info (Error/Checksum): Bad checksum [should be 0xa6752ff1]]
            [Bad checksum [should be 0xa6752ff1]]
            [Severity level: Error]
            [Group: Checksum]
    [CRC Status: Bad]
    EOF: Unknown (0x00000000)
Fibre Channel
    R_CTL: 0x7(Device_Data/Command Status)
    Dest Addr: 9f.7a.fd
    CS_CTL: 0x7c
    Src Addr: 6c.0f.09
    Type: Unknown (0x3f)
    F_CTL: 0x0f6741, ExgRpd: Exchange Originator, SeqRec: Seq Initiator, ExgFst: NOT exchg first, ExgLst: NOT exchg last, SeqLst: Seq Last, Pri: Priority, TSI: Transfer Seq Initiative, LDF: Unknown, A01: Unknown, RetSeq: Retransmitted Sequence
        0... .... .... .... .... .... = ExgRpd: Exchange Originator
        .0.. .... .... .... .... .... = SeqRec: Seq Initiator
        ..0. .... .... .... .... .... = ExgFst: NOT exchg first
        ...0 .... .... .... .... .... = ExgLst: NOT exchg last
        .... 1... .... .... .... .... = SeqLst: Seq Last
        .... ..1. .... .... .... .... = Pri: Priority
        .... ...1 .... .... .... .... = TSI: Transfer Seq Initiative
        .... .... 01.. .... .... .... = LDF: Unknown (0x1)
        .... .... ..10 .... .... .... = A01: Unknown (0x2)
        .... .... .... ..1. .... .... = RetSeq: Retransmitted Sequence
        .... .... .... .... ..00 .... = AA: ABTS - Cont (0x0)
        .... .... .... .... .... 0... = RelOff: rel offset NOT set
    SEQ_ID: 0x06
    DF_CTL: 0x7d
    SEQ_CNT: 56449
    OX_ID: 0x41c5
    RX_ID: 0xd407
    Parameter: 0x9df4abf8
    Network DA: 6e:4e:e8:b0:8f:f6:63:ca
    Network SA: f2:a5:e7:f4:68:7d:be:a3
Data (888 bytes)
    Data: 61b2066247472dabb80f16cf985095bc1cf512cd6c1c8d62…
    [Length: 888]

0000  bc b5 58 58 07 9f 7a fd 7c 6c 0f 09 3f 0f 67 41   ..XX..z.|l..?.gA
0010  06 7d dc 81 41 c5 d4 07 9d f4 ab f8 6e 4e e8 b0   .}..A.......nN..
0020  8f f6 63 ca f2 a5 e7 f4 68 7d be a3 61 b2 06 62   ..c.....h}..a..b
0030  47 47 2d ab b8 0f 16 cf 98 50 95 bc 1c f5 12 cd   GG-......P......
0040  6c 1c 8d 62 a7 9d 8a 40 c2 6d 63 bd 66 e6 4a f7   [email protected].
0050  69 95 2b 8c df 41 9f cd 7c f4 60 08 4a 9e 1b 9f   i.+..A..|.`.J...
0060  2d 8d 3e 25 99 dd fd b7 28 7c 32 9d 19 2b 94 8f   -.>%....(|2..+..
0070  25 3e f0 4d 54 af 5e 2f d7 16 48 e9 74 79 a7 64   %>.MT.^/..H.ty.d
0080  17 7a cd 13 d4 47 2c 9f f9 1b ca ac 2e 39 10 7b   .z...G,......9.{
0090  1e ae d9 2f 78 79 43 75 0a 46 b9 58 f4 44 50 30   .../xyCu.F.X.DP0
00a0  20 46 de 9d 71 54 81 b5 d4 55 0e 5f 3e 88 c7 69    F..qT...U._>..i
00b0  ab 3e 86 43 71 67 a7 65 49 43 5f 92 93 7b 5f ed   .>.Cqg.eIC_..{_.
00c0  75 f1 12 19 04 3c 19 7a 4e 4c fe 73 fb 9a c7 6f   u....<.zNL.s...o
00d0  74 c8 a9 72 38 58 4a 8c d6 5a ec 1b 0f be 16 ed   t..r8XJ..Z......
00e0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
00f0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0100  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0110  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0120  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0130  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0140  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0150  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0160  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0170  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0180  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0190  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01a0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01b0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01c0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01d0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01e0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01f0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0200  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0210  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0220  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0230  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0240  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0250  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0260  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0270  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0280  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0290  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
02a0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
02b0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
02c0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
02d0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
02e0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
02f0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0300  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0310  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0320  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0330  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0340  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0350  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0360  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0370  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0380  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0390  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
03a0  00 00 00 00 00 00 00 00 00 00 00 00               ............

tl_hpg_ctrler binding to GND

Synthesis warning:

Warning (12011): Net is missing source, defaulting to GND
    Warning (12110): Net "fejkon_pcie:pcie|pcie_data_config_tl_hpg_ctrler[4]" is missing source, defaulting to GND File: /home/bluecmd/fejkon/gen/db/ip/fejkon/submodules/fejkon_pcie.v Line: 131
    Warning (12110): Net "fejkon_pcie:pcie|pcie_data_config_tl_hpg_ctrler[3]" is missing source, defaulting to GND File: /home/bluecmd/fejkon/gen/db/ip/fejkon/submodules/fejkon_pcie.v Line: 131
    Warning (12110): Net "fejkon_pcie:pcie|pcie_data_config_tl_hpg_ctrler[2]" is missing source, defaulting to GND File: /home/bluecmd/fejkon/gen/db/ip/fejkon/submodules/fejkon_pcie.v Line: 131
    Warning (12110): Net "fejkon_pcie:pcie|pcie_data_config_tl_hpg_ctrler[1]" is missing source, defaulting to GND File: /home/bluecmd/fejkon/gen/db/ip/fejkon/submodules/fejkon_pcie.v Line: 131
    Warning (12110): Net "fejkon_pcie:pcie|pcie_data_config_tl_hpg_ctrler[0]" is missing source, defaulting to GND File: /home/bluecmd/fejkon/gen/db/ip/fejkon/submodules/fejkon_pcie.v Line: 131

They should be set to GND, so no harm right now - but it should be explicitly set long-term.

Transceiver timing

The report for the new xcvrs look weird and fail timing:

+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
; Fmax                                                                                                                                                                                                                                                                      ;
+-------------+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------+
; Fmax        ; Restricted Fmax ; Clock Name                                                                                                                                                                               ; Note                                           ;
+-------------+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------+
; 84.82 MHz   ; 84.82 MHz       ; clk_clk                                                                                                                                                                                  ;                                                ;
; 86.39 MHz   ; 86.39 MHz       ; altera_reserved_tck                                                                                                                                                                      ;                                                ;
; 256.48 MHz  ; 256.48 MHz      ; pcie|phy|altera_s5_a2p|altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip|coreclkout                                                                                                    ;                                                ;
; 1226.99 MHz ; 560.22 MHz      ; fcport0|xcvr|phy|fc_phy_inst|S5|transceiver_core|gen.sv_xcvr_native_insts[0].gen_bonded_group.sv_xcvr_native_inst|inst_sv_pcs|ch[0].inst_sv_pcs_ch|inst_sv_hssi_8g_tx_pcs|wys|clkout     ; limit due to minimum period restriction (tmin) ;
; 1228.5 MHz  ; 560.22 MHz      ; fcport0|xcvr|phy|fc_phy_inst|S5|transceiver_core|gen.sv_xcvr_native_insts[0].gen_bonded_group.sv_xcvr_native_inst|inst_sv_pcs|ch[0].inst_sv_pcs_ch|inst_sv_hssi_8g_rx_pcs|wys|clocktopld ; limit due to minimum period restriction (tmin) ;
+-------------+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------+

Reset temp. sensor

Right now the temp sensor does one measurement at power-on and that's it.

Enabling the ADC allows you to measure the device temperature only once. To
perform another temperature measurement, assert the clr signal, or reset the
device. The clr signal is asynchronous, and you must assert the clr signal at least
one clock cycle of the ADC clk signal to clear the output ports.

Enable the CLR port and drive it from the intel_temp IP.

Reset pipelining

There seems to be some issues with the reset synchronizer and meeting timing lately.

Let's sprinkle some pipelining steps for the reset.

Traffic generator for PCIe benchmark

Add a traffic generator that can be enabled to stress-test PCIe.

Ideas:

  • CSR to configure a delay between packets - 0 meaning go as fast as possible

Together with an Avalon-ST Mux it should be easy to add this as a separate channel and thus a separate network interface in Linux

Investigate AER issues

On a cold-boot, a modprobe fejkon produces this:

 		UESta:	DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
 		UEMsk:	DLP- SDES- TLP+ FCP- CmpltTO- CmpltAbrt+ UnxCmplt+ RxOF- MalfTLP- ECRC- UnsupReq+ ACSViol-
 		UESvrt:	DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
-		CESta:	RxErr+ BadTLP- BadDLLP+ Rollover- Timeout- NonFatalErr-
+		CESta:	RxErr+ BadTLP+ BadDLLP+ Rollover- Timeout- NonFatalErr+
 		CEMsk:	RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+

I.e we have triggered BadTLP+ I guess?

Support PCIe 2.0

When trying to figure out a way to more quickly iterate I considered changing the PCIe generation to 2.0. It would bring down the effective bandwidth to max 4 GB/s from 7.8 GB/s but that's still plenty to work with.

It should be as simple as:

diff --git a/fejkon_pcie.tcl b/fejkon_pcie.tcl
index a41dcb3..b840e4f 100644
--- a/fejkon_pcie.tcl
+++ b/fejkon_pcie.tcl
@@ -22,7 +22,7 @@ set_instance_parameter_value alt_xcvr_reconfig_0 {enable_offset} {1}
 set_instance_parameter_value alt_xcvr_reconfig_0 {gui_cal_status_port} {0}
 set_instance_parameter_value alt_xcvr_reconfig_0 {gui_enable_pll} {0}
 set_instance_parameter_value alt_xcvr_reconfig_0 {gui_split_sizes} {}
-set_instance_parameter_value alt_xcvr_reconfig_0 {number_of_reconfig_interfaces} {11}
+set_instance_parameter_value alt_xcvr_reconfig_0 {number_of_reconfig_interfaces} {10}
 
 add_instance bar2_cdc altera_avalon_mm_clock_crossing_bridge 19.1
 set_instance_parameter_value bar2_cdc {ADDRESS_UNITS} {SYMBOLS}
@@ -99,8 +99,8 @@ set_instance_parameter_value mgmt_rst {USE_RESET_REQUEST} {0}
 
 add_instance pcie_reconfig_driver_0 altera_pcie_reconfig_driver 19.1
 set_instance_parameter_value pcie_reconfig_driver_0 {enable_cal_busy_hwtcl} {0}
-set_instance_parameter_value pcie_reconfig_driver_0 {gen123_lane_rate_mode_hwtcl} {Gen3 (8.0 Gbps)}
-set_instance_parameter_value pcie_reconfig_driver_0 {number_of_reconfig_interfaces} {11}
+set_instance_parameter_value pcie_reconfig_driver_0 {gen123_lane_rate_mode_hwtcl} {Gen2 (5.0 Gbps)}
+set_instance_parameter_value pcie_reconfig_driver_0 {number_of_reconfig_interfaces} {10}
 
 add_instance pcie_reset pcie_reset 1.0
 
@@ -256,7 +256,7 @@ set_instance_parameter_value phy {flow_control_timeout_count_advanced_default_hw
 set_instance_parameter_value phy {flow_control_update_count_advanced_default_hwtcl} {30}
 set_instance_parameter_value phy {force_hrc} {0}
 set_instance_parameter_value phy {force_src} {0}
-set_instance_parameter_value phy {gen123_lane_rate_mode_hwtcl} {Gen3 (8.0 Gbps)}
+set_instance_parameter_value phy {gen123_lane_rate_mode_hwtcl} {Gen2 (5.0 Gbps)}
 set_instance_parameter_value phy {gen2_diffclock_nfts_count_advanced_default_hwtcl} {255}
 set_instance_parameter_value phy {gen2_sameclock_nfts_count_advanced_default_hwtcl} {255}
 set_instance_parameter_value phy {gen3_rxfreqlock_counter_hwtcl} {0}

However the above simply results in no PCIe device being detected. There is another example of somebody else successfully running at 2.0.

Could this be the host having problems re-training for 2.0 after 3.0 was used initially? The factory image uses Gen 3, so maybe the answer is to flash a 2.0 image onto the factory flash. Alternatively power the board and JTAG the firmware before the PCH boots.

I also tried changing the number of MSIs to 4 from 32 to see if it was a limitation in Gen 2, but that didn't change anything.

ModelSim testbenches w/ Quartus 20.1 broken?

Both the PCIe testbench and the FC XCVR testbench seems to error out on this part:

# ** Error: ../intelFPGA/20.1/quartus/eda/sim_lib/mentor/stratixv_atoms_ncrypt.v(38): (vlog-2163) Macro `<protected> is undefined.
# ** Error: ../intelFPGA/20.1/quartus/eda/sim_lib/mentor/stratixv_atoms_ncrypt.v(38): (vlog-2163) Macro `<protected> is undefined.
# ** Error: (vlog-13069) ../intelFPGA/20.1/quartus/eda/sim_lib/mentor/stratixv_atoms_ncrypt.v(38): syntax error in protected region.
# 
# ** Error: ../intelFPGA/20.1/quartus/eda/sim_lib/mentor/stratixv_atoms_ncrypt.v(38): (vlog-13205) Syntax error found in the scope following '<protected>'. Is there a missing '::'?
# End time: 23:08:09 on Aug 20,2020, Elapsed time: 0:00:00
# Errors: 5, Warnings: 0

I am positive this has worked in the past. I will have to compare some versions.

A clean checkout did not change anything.

Things I have tried quickly:

  • Clean checkout with regenerated Altera FC PHY IP
  • Compared the Altera FC PHY IP dev_com and generated testbench. Seem to match, but only skimmed.

SignalTap integration

The hardware is quite complex right now and doing SignalTap rebuilds are annoying.

It might be useful to have a central SignalTap integration enabled by a "Debug" menu entry (or several?) in the menuconfig interface.

Like:

  • Debugging
    • Instrument FC ingest and state machine
    • Instrument FC debug and generator
    • Instrument C2H TLP generation
    • Instrument PCIe TLP reception and response

Best would probably be if we don't have to include actual IPs in the source code, but if we have to so be it.

Project: FejkonX

After a big break and mentally going over things that need to be debugged and issues I'm having, mostly related to PCIe, I have decided to put this project to sleep and start a new intermediate project called FejkonX.

The difference will be that FejkonX will use a static 3x SFP+ ports, 2x FC8 and 1x 10G Ethernet. No PCIe. It will support capturing/mirroring FC traffic as well as sending/receiving it over Ethernet. TX pacing will be left to the Ethernet sender as it would have to implement an FC stack anyway.

This should significantly decrease the complexity of Fejkon and provide a nice middle ground to get something real up and running.

The same IP cores related to FC and such will of course be reused.

Add FC-AL-2 IDLEs to state_rx

According to FC-AL-2

The Arbitrate Primitive Signal (ARByx) may be transmitted in place of an Idle and therefore becomes a Fill Word which may be removed for clock skew management

A received Ordered Set shall be detected as an Arbitrate Primitive Signal (ARByx) by detecting that its first two characters (fully decoded) are equal to the value shown in table 2, regardless of the value of characters 3 and 4 (y and x). L_Ports shall only
originate an Arbitrate Primitive Signal (ARByx) where y = x. All Arbitrate Primitive Signals shall be treated as Fill Words for clock skew management.

So technically all ARByx are idles as well.

This would help a bit to make sense of things in #52 where ARB(EF) was seen as an idle word.

Payload endianness

From a capture it can be seen that the data is endian swapped.

Capturing on 'fc0'
    1 0.000000000     be.ad.de → be.ad.de     FC 64 Unknown frame

0000  ef be ad de ef be ad de ef be ad de ef be ad de   ................
0010  ef be ad de ef be ad de ef be ad de ef be ad de   ................
0020  de c0 ad ba de c0 ad ba de c0 ad ba de c0 ad ba   ................
0030  de c0 ad ba de c0 ad ba de c0 ad ba de c0 ad ba   ................

This is set in code as [255:0] <= 256'hdeadbeefdeadbeef...;.
Normally I would assume this is just some big-endian / little-endian swapping that needs to be done but since the header is also set using [31:0] <= ... and does not need swapping (it is correct out of the box) that makes me a bit confused what is going on.

Needs investigation,

NAPI poll budget logic wrong

When looking at the poll code for using as a NAPI example I saw that the budget logic is likely bananas:

fejkon/driver/src/board.c

Lines 132 to 141 in 9b7dd8f

dev_dbg(&card->pci->dev, "poll budget = %d, processed = %d",
budget, work_done);
if (work_done < budget) {
napi_complete(napi);
// Update read pointer and re-enable IRQ
iowrite32(
card->rx_buf_start_dma + (card->rx_buf_read - card->rx_buf_start),
card->bar0 + 0x8A8);
}
return work_done;

This is likely supposed to check work_done < budget every packet cycle and at the end, regardless of that invariant, the new read pointer should be updated.

Recovery timing violation

----------------
; Command Info ;
----------------
Report Timing: Found 1 recovery paths (1 violated).  Worst case slack is -0.115 

Tcl Command:
    report_timing -append -recovery -multi_corner -file violated_paths.txt -panel_name {Violated recovery paths for 2_H2_slow_900mv_85c} -less_than_slack 0 -npaths 10 -detail full_path

Options:
    -recovery 
    -less_than_slack 0 
    -npaths 10 
    -detail full_path 
    -panel_name {Violated recovery paths for 2_H2_slow_900mv_85c} 
    -file {violated_paths.txt} 
    -append 
    -multi_corner 

Delay Model:
    Slow 900mV 85C Model

+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
; Summary of Paths                                                                                                                                                                                                                                                                                                                     ;
+--------+-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+--------------+-------------------------------------------------------------------------+--------------+------------+------------+
; Slack  ; From Node                                     ; To Node                                                                                                                                   ; Launch Clock ; Latch Clock                                                             ; Relationship ; Clock Skew ; Data Delay ;
+--------+-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+--------------+-------------------------------------------------------------------------+--------------+------------+------------+
; -0.115 ; fejkon_pcie:pcie|pcie_reset:pcie_reset|rst_rr ; fejkon_pcie:pcie|altpcie_sv_hip_ast_hwtcl:phy|altpcie_hip_256_pipen1b:altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip~SYNC_DATA_REG13 ; clk_clk      ; pcie|phy|altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip|coreclkout ; 4.000        ; 1.009      ; 5.024      ;
+--------+-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+--------------+-------------------------------------------------------------------------+--------------+------------+------------+

Path #1: Recovery slack is -0.115 (VIOLATED)
===============================================================================
+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
; Path Summary                                                                                                                                                   ;
+--------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
; Property           ; Value                                                                                                                                     ;
+--------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
; From Node          ; fejkon_pcie:pcie|pcie_reset:pcie_reset|rst_rr                                                                                             ;
; To Node            ; fejkon_pcie:pcie|altpcie_sv_hip_ast_hwtcl:phy|altpcie_hip_256_pipen1b:altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip~SYNC_DATA_REG13 ;
; Launch Clock       ; clk_clk                                                                                                                                   ;
; Latch Clock        ; pcie|phy|altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip|coreclkout                                                                   ;
; Data Arrival Time  ; 8.925                                                                                                                                     ;
; Data Required Time ; 8.810                                                                                                                                     ;
; Slack              ; -0.115 (VIOLATED)                                                                                                                         ;
+--------------------+-------------------------------------------------------------------------------------------------------------------------------------------+

+-----------------------------------------------------------------------------------+
; Statistics                                                                        ;
+------------------------+-------+-------+-------------+------------+-------+-------+
; Property               ; Value ; Count ; Total Delay ; % of Total ; Min   ; Max   ;
+------------------------+-------+-------+-------------+------------+-------+-------+
; Recovery Relationship  ; 4.000 ;       ;             ;            ;       ;       ;
; Clock Skew             ; 1.009 ;       ;             ;            ;       ;       ;
; Data Delay             ; 5.024 ;       ;             ;            ;       ;       ;
; Number of Logic Levels ;       ; 1     ;             ;            ;       ;       ;
; Physical Delays        ;       ;       ;             ;            ;       ;       ;
;  Arrival Path          ;       ;       ;             ;            ;       ;       ;
;   Clock                ;       ;       ;             ;            ;       ;       ;
;    IC                  ;       ; 3     ; 3.072       ; 79         ; 0.000 ; 2.220 ;
;    Cell                ;       ; 3     ; 0.829       ; 21         ; 0.212 ; 0.323 ;
;   Data                 ;       ;       ;             ;            ;       ;       ;
;    IC                  ;       ; 2     ; 4.097       ; 82         ; 1.634 ; 2.463 ;
;    Cell                ;       ; 3     ; 0.927       ; 18         ; 0.000 ; 0.834 ;
;    uTco                ;       ; 1     ; 0.000       ; 0          ; 0.000 ; 0.000 ;
;  Required Path         ;       ;       ;             ;            ;       ;       ;
;   Clock                ;       ;       ;             ;            ;       ;       ;
;    IC                  ;       ; 2     ; 3.407       ; 69         ; 1.144 ; 2.263 ;
;    Cell                ;       ; 3     ; 1.503       ; 31         ; 0.147 ; 0.840 ;
+------------------------+-------+-------+-------------+------------+-------+-------+
Note: Negative delays are omitted from totals when calculating percentages

+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
; Data Arrival Path                                                                                                                                                                                                            ;
+---------+---------+----+------+--------+----------------------------+------------+-------------------------------------------------------------------------------------------------------------------------------------------+
; Total   ; Incr    ; RF ; Type ; Fanout ; Location                   ; HS/LP      ; Element                                                                                                                                   ;
+---------+---------+----+------+--------+----------------------------+------------+-------------------------------------------------------------------------------------------------------------------------------------------+
; 0.000   ; 0.000   ;    ;      ;        ;                            ;            ; launch edge time                                                                                                                          ;
; 3.901   ; 3.901   ;    ;      ;        ;                            ;            ; clock path                                                                                                                                ;
;   0.000 ;   0.000 ;    ;      ;        ;                            ;            ; source latency                                                                                                                            ;
;   0.000 ;   0.000 ;    ;      ; 1      ; PIN_AW35                   ;            ; clk_clk                                                                                                                                   ;
;   0.000 ;   0.000 ; RR ; IC   ; 1      ; IOIBUF_X4_Y0_N1            ;            ; clk_clk~input|i                                                                                                                           ;
;   0.323 ;   0.323 ; RR ; CELL ; 1      ; IOIBUF_X4_Y0_N1            ;            ; clk_clk~input|o                                                                                                                           ;
;   1.175 ;   0.852 ; RR ; IC   ; 3      ; CLKCTRL_G1                 ;            ; clk_clk~inputCLKENA0|inclk                                                                                                                ;
;   1.387 ;   0.212 ; RR ; CELL ; 27938  ; CLKCTRL_G1                 ;            ; clk_clk~inputCLKENA0|outclk                                                                                                               ;
;   3.607 ;   2.220 ; RR ; IC   ; 1      ; FF_X4_Y29_N32              ; High Speed ; pcie|pcie_reset|rst_rr|clk                                                                                                                ;
;   3.901 ;   0.294 ; RR ; CELL ; 1      ; FF_X4_Y29_N32              ; High Speed ; fejkon_pcie:pcie|pcie_reset:pcie_reset|rst_rr                                                                                             ;
; 8.925   ; 5.024   ;    ;      ;        ;                            ;            ; data path                                                                                                                                 ;
;   3.901 ;   0.000 ;    ; uTco ; 1      ; FF_X4_Y29_N32              ;            ; fejkon_pcie:pcie|pcie_reset:pcie_reset|rst_rr                                                                                             ;
;   3.901 ;   0.000 ; RR ; CELL ; 2      ; FF_X4_Y29_N32              ; High Speed ; pcie|pcie_reset|rst_rr|q                                                                                                                  ;
;   5.535 ;   1.634 ; RR ; IC   ; 1      ; MLABCELL_X3_Y29_N36        ; High Speed ; pcie|phy|altpcie_hip_256_pipen1b|npor_int|datae                                                                                           ;
;   5.628 ;   0.093 ; RF ; CELL ; 9      ; MLABCELL_X3_Y29_N36        ; High Speed ; pcie|phy|altpcie_hip_256_pipen1b|npor_int|combout                                                                                         ;
;   8.091 ;   2.463 ; FF ; IC   ; 1      ; HSSIGEN3PCIEHIP_X0_Y21_N79 ; High Speed ; pcie|phy|altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip|corepor                                                                      ;
;   8.925 ;   0.834 ; FR ; CELL ; 0      ; HSSIGEN3PCIEHIP_X0_Y21_N79 ;            ; fejkon_pcie:pcie|altpcie_sv_hip_ast_hwtcl:phy|altpcie_hip_256_pipen1b:altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip~SYNC_DATA_REG13 ;
+---------+---------+----+------+--------+----------------------------+------------+-------------------------------------------------------------------------------------------------------------------------------------------+

+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
; Data Required Path                                                                                                                                                                                                           ;
+---------+---------+----+------+--------+----------------------------+------------+-------------------------------------------------------------------------------------------------------------------------------------------+
; Total   ; Incr    ; RF ; Type ; Fanout ; Location                   ; HS/LP      ; Element                                                                                                                                   ;
+---------+---------+----+------+--------+----------------------------+------------+-------------------------------------------------------------------------------------------------------------------------------------------+
; 4.000   ; 4.000   ;    ;      ;        ;                            ;            ; latch edge time                                                                                                                           ;
; 8.910   ; 4.910   ;    ;      ;        ;                            ;            ; clock path                                                                                                                                ;
;   4.000 ;   0.000 ;    ;      ;        ;                            ;            ; source latency                                                                                                                            ;
;   4.000 ;   0.000 ;    ;      ; 1      ; HSSIGEN3PCIEHIP_X0_Y21_N79 ;            ; pcie|phy|altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip|observablecoreclkdiv                                                         ;
;   4.840 ;   0.840 ; RR ; CELL ; 1      ; HSSIGEN3PCIEHIP_X0_Y21_N79 ;            ; pcie|phy|altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip|coreclkout                                                                   ;
;   5.984 ;   1.144 ; RR ; IC   ; 1      ; CLKCTRL_G0                 ; High Speed ; pcie|phy|altpcie_hip_256_pipen1b|coreclkout_hip~CLKENA0|inclk                                                                             ;
;   6.131 ;   0.147 ; RR ; CELL ; 2171   ; CLKCTRL_G0                 ;            ; pcie|phy|altpcie_hip_256_pipen1b|coreclkout_hip~CLKENA0|outclk                                                                            ;
;   8.394 ;   2.263 ; RR ; IC   ; 142    ; HSSIGEN3PCIEHIP_X0_Y21_N79 ;            ; pcie|phy|altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip|pldclk                                                                       ;
;   8.910 ;   0.516 ; RR ; CELL ; 0      ; HSSIGEN3PCIEHIP_X0_Y21_N79 ;            ; fejkon_pcie:pcie|altpcie_sv_hip_ast_hwtcl:phy|altpcie_hip_256_pipen1b:altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip~SYNC_DATA_REG13 ;
; 8.810   ; -0.100  ;    ;      ;        ;                            ;            ; clock uncertainty                                                                                                                         ;
; 8.810   ; 0.000   ;    ; uTsu ; 0      ; HSSIGEN3PCIEHIP_X0_Y21_N79 ;            ; fejkon_pcie:pcie|altpcie_sv_hip_ast_hwtcl:phy|altpcie_hip_256_pipen1b:altpcie_hip_256_pipen1b|stratixv_hssi_gen3_pcie_hip~SYNC_DATA_REG13 ;
+---------+---------+----+------+--------+----------------------------+------------+-------------------------------------------------------------------------------------------------------------------------------------------+

Expose Ethernet SFP I2C devices

Even though the ethernet ports are not managed by the Linux driver, it would be useful to expose the I2C interface to userspace so it can be monitored.

Fejkon I2C driver is noisy on timeouts

When doing an i2cdetect -r 2 we print a lot of:

[ 4827.525094] fejkon 0000:b3:00.0 port1 i2c: Core Status not IDLE...
[ 4827.525594] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.525714] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.525719] fejkon 0000:b3:00.0 port1 i2c: Core Status not IDLE...
[ 4827.526222] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.526341] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.526347] fejkon 0000:b3:00.0 port1 i2c: Core Status not IDLE...
[ 4827.526856] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.526975] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.526981] fejkon 0000:b3:00.0 port1 i2c: Core Status not IDLE...
[ 4827.527481] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.527616] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.527741] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.527866] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.527873] fejkon 0000:b3:00.0 port1 i2c: Core Status not IDLE...
[ 4827.528433] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.528552] fejkon 0000:b3:00.0 port1 i2c: Could not get ACK
[ 4827.528557] fejkon 0000:b3:00.0 port1 i2c: Core Status not IDLE...

We are nice and quiet when addressing units that exists however.

Implement 6.3.4.2 Detection of an invalid Transmission Word

It seems like we get a proper link synchronization with a remote QLogic card, but the link does not go up.

Not surprising, as we only send IDLE and it was pretty naive to assume something would work :-).

Next step would be to implement the port initialization state machine.

Release WAKE_N

We shouldn't be causing PCIe Wake-Up

PCIE_WAKE_n Wake signal 2.5-V PIN_BD35

Transceiver equalization and Eye viewer

Right now the signal integrity on the SFP channels has not been a issue, and likely will not be.

However I have been playing around with the Eye viewer and it seems pretty fun.

A couple of observations:

  • Doing auto sweep and enabling the equalizer seems to result in a much wider eye
  • The links are not auto detected and need to painfully be manually configured

It would be cool to maybe surface this eye measurements in an bit more easy fashion than having to manually define the links. The eye measurement also seems to error out with a "null" error and that the reconfiguration controller is currently busy. Might be solveable.

FC PHY support for odd alignment

Even though IRL the XCVR seems to lock and align from what I've seen, I've managed to find cases where the XCVR locks on with the K28.5 symbol in offset 1. We only support 0 and 2 for now, but 1 and 3 shouldn't be that annoying to implement.

CI testing

For a lot of tests we can use CI, and definitely for linting.

Introduce a make target that does all that testing and use it for CI.

Si570 support

The other clocks have an incompatible base clock (25 MHz).

Figure out a good way to use the Si570 oscillator.

Frame (de)scrambling

8GFC shall use frame scrambling and emission lowering protocol as stated in FC-FS-3 (reference [33]).

This is very likely why our captured data looks a bit iffy right now.

Implement ndo_change_carrier

Since we are doing userspace Fibre Channel we want to keep the DMA and the netdevs hot even when the link is down.
Right now doing ip link set up activates the lasers which will cause the initial FC packets to start to flow. This means that between the up and the pcap attachment we will likely lose packets.

Thus we need a way to be able to reset the interface from userspace without taking it down/up. The IFLA_CARRIER is not meant for this, but we can re-use it as a way to force control of the TX laser which will cause a FC state reset.

Save unsupported TLPs

Right now we only log the amount, we should save the last insupported TLP as well for debugging.

FC primitive stats in /sys

It would be nice to have access to the primitive stats in /sys - and also to reset the counters. Possibly exported straight away in Prometheus format for ingestion by node_exporter.

This is most likely done easiest by changing the mgmt interface on the xcvr to be clocked by the tx/rx respectively to avoid cdcs in the RTL and have them inferred instead

FC<->Ethernet mode

If PCIe continues to be a hassle it might be worth to figure out how to get the CDCM61001 clock up and running.

That would allow another clock source for use for Ethernet.
For a 156.25 MHz clock (10GigE) it seems driving PR1=1, PR0=0 , OD0=1, OD1=1, OD2=0 will do the trick.

After specifying the desired output frequency in the parallel interface, developers must assert the output enable pin CE and control the RSTN pin to generate a rising signal to start the PLL Recalibration process. In the FPGA board, the required output type is LVDS, so always set OS0 and SO1 to 0 and 1, respectively.

Likely this is going to be the clock pin: U53 SFP1G_REFCLK_p 125.0 MHz LVDS PIN_AH6 which we will obviously call something else.

The clock config pins are configured by the MAX II, so there is likely going to be some need to talk to it:

CDCM61001 (U53)
PLL_SCL 2.5-V PIN_AF32
PLL_SDA 2.5-V PIN_AG32
I2C bus, connected with MAX II CPLD

Something like this (generated from builder):

//=======================================================
//  CDCM61001/CDCM61004 External PLL Configuration 
//      Configure CDCM61001 as 156.25 MHz
//      Configure CDCM61004 as Disabled
//=======================================================

//  Signal declarations
wire [ 3: 0] clk1_set_wr, clk2_set_wr, clk3_set_wr;
wire         rstn;
wire         conf_ready;
wire         counter_max;
wire  [7:0]  counter_inc;
reg   [7:0]  auto_set_counter;
reg          conf_wr;

//  Structural coding
assign clk1_set_wr = 4'd7; //156.25 MHz
assign clk2_set_wr = 4'd1; //Disabled
assign clk3_set_wr = 4'd0; //Unchange

assign rstn = CPU_RESET_n;
assign counter_max = &auto_set_counter;
assign counter_inc = auto_set_counter + 1'b1;

always @(posedge OSC_50_B3B or negedge rstn)
	if(!rstn)
	begin
		auto_set_counter <= 0;
		conf_wr <= 0;
	end 
	else if (counter_max)
		conf_wr <= 1;
	else
		auto_set_counter <= counter_inc;


ext_pll_ctrl ext_pll_ctrl_Inst(
	.osc_50(OSC_50_B3B), //50MHZ
	.rstn(rstn),

	// device 1 (SFP1G_REFCLK_p)
	.clk1_set_wr(clk1_set_wr),
	.clk1_set_rd(),

	// device 2 (SATA_HOST_REFCLK_p/SATA_DEVICE_REFCLK_p)
	.clk2_set_wr(clk2_set_wr),
	.clk2_set_rd(),

	// device 3 (reserved)
	.clk3_set_wr(clk3_set_wr),
	.clk3_set_rd(),

	// setting trigger
	.conf_wr(conf_wr), // 1T 50MHz 
	.conf_rd(), // 1T 50MHz

	// status 
	.conf_ready(conf_ready),

	// 2-wire interface 
	.max_sclk(PLL_SCL),
	.max_sdat(PLL_SDA)

);

endmodule

The values for both clk1 and clk2 seems to align.
Other known values are:

0 = Unchanged
1 = Disabled
2 = 62.5 MHz
3 = 75 MHz
4 = 100 MHz
5 = 125 MHz
6 = 150 MHz
7 = 156.25 MHz
8 = 187.50 MHz
9 = 200 MHz
10 = 250 MHz
11 = 312.5 MHz
12 = 625 MHz

Creating an IP core for configuring the two clocks seems like the best thing to do.

Record commit for .sof and make syscon warn if mismatch

  • Create a fejkon.sof.git with the revision hash in it
  • Make syscon load fejkon.sof on startup
  • Warn if the detected board is not using the same revision

This should be what device_get_design does in System Console but it seems to not do anything.

Fan control

Since the fan is noisy it would be useful to implement the fan to turn on if the temperature reaches say 60 degrees.

FAN_CTRL, 2.5-V, PIN_AR32 should be able to do this.

The FAN is turned on when the FAN_CTRL pin is driven to a high logic level.

Traffic capture of raw primitives

From playing around with fejkon with some actual FC traffic it has become clear that there will be a need to capture behavior on the primitives.

For example when debugging why Brocade loopbacks wouldn't come up in #26 it seems the Brocade switch sends a bunch of primitives that fejkon 1) does not know about and 2) implementing would be infeasible.

Switching to xcvr <-> xcvr based mode is in progress which means that supporting this kind of traffic will be done, but in order to analyze this kind of low-level traffic there needs to be a way to capture essentially a waveform of the primitives.

I have been thinking about something like this:

                        csr
                         +
                         |
                    +----v---------+           +------------+
                    |              |           |            |
    +---------+     |              +---------->+   Memory   <-------+
+-->+  Port 0 +---->+              |           |            |       |
    +---------+     |      RLE     |           +------------+       |
    +---------+     |    Encoder   |           +------------+       |
+-->+  Port 1 +---->+              |           |            |       |
    +---------+     |              +---------->+   Memory   <-------+
                    |              |           |            |       |
                    +-----^--------+           +------------+       |
                          |                                         |
                          +                                         |
                      106.25 MHz                                    |
                                                                    |
                                                                    |
                                                                    +
                                                                  Data

Writing to a fixed-sized memory should allow one to trigger a ~synchronized capture of Port 0 and 1 being written to two memories encoded using RLE. A simple data format such as 64-bit formatted as 24-bit count | 4-bit metadata | 4-bit K-value | 32-bit value should be fine. 24-bit counter means that a fully idle stream will write out 7x idle frames every second as the counter wrap around is reached. This should be ample for our needs.

Investigate asynchronous and active-low reset

From the LowRISC style guide it is apparent that they are using asynchronous reset and active-low.
Thinking about it, that does make a whole lot of sense, and might mean that reset in Qsys do not need to be associated with clocks anymore? That would help the design to be less complex.

They use sections like these:

  always_ff @(posedge clk_i or negedge rst_ni) begin : p_regs
    if (!rst_ni) begin
      dio_attr_q <= '0;
      mio_attr_q <= '0;
    end else begin
    end
  end

We should:

  • Have a look what the other Qsys IPs are doing
  • Evaluate switching by changing e.g. the data path and see how that affects timing

C2H DMA Master Bug

  • C2H DMA implemented in QEMU
  • C2H DMA implemented in driver
  • C2H DMA implemented in HDL
    • Avalon-ST ingest and TLP construction
    • Packet available IRQ implemented
    • Packet overflow protection and IRQ implemented
    • Testbenches for C2H DMA
    • TLP fragmentation
  • Synchronize QEMU and driver to final header format in HDL

Traffic Generator needs to respect _ready

The TLP constructed for a 16x DW traffic generator session is:

 Last TLP TX Data     : 0x4000000c 0xb30000ff 0x34480000 0x00000000 0x00000084 0x00000000 0x00000000 0x00000000

This is only 8x DW.

Also the staging counter stops and does not increment past 3.

4x Tx/Rx memories for PCIe DMA

Right now we have two 1 MB RAMs for TX and RX.

Since the secondary slave port will be driven by the FC Port DMA and can trivially be partitioned on a per-port basis, we should do that.

  • Change fejkon_pcie to have 4x TX and 4x RX Avalon-MM slave ports for the RAMs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.