# ecdufcdrvr/bcmufctdrvr architecture

> Architecture diagram of the GitHub repository ecdufcdrvr/bcmufctdrvr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ecdufcdrvr/bcmufctdrvr
- Repository: https://github.com/ecdufcdrvr/bcmufctdrvr

## Overview

This project is a specialized user-mode Fibre Channel (FC) target driver module designed to integrate with the Storage Performance Development Kit (SPDK) NVMe target application. Its purpose is to provide a low-level FC driver (LLD) that supports selected Broadcom/Emulex Fibre Channel devices in a SPDK environment.

##### Project Components
- SPDK NVMe Target: The external, larger SPDK framework that hosts the FC driver module.
- FC Driver Module: The core of the project, which consists of multiple C source files (in the src directory) and headers (in include). This module implements:
– Initialization routines, device management, configuration, and control interfaces.
– Low-level functionalities such as error handling, debugging (ocs_debug.c/.h), memory buffers, IO operations, and hardware interfacing (e.g., ocs_device, ocs_hal, sli4, etc.).
– Specialized components for Fibre Channel operations (e.g., ocs_els, ocs_fabric, ocs_scsi).
- Build and Configuration Scripts:
– Makefile: Governs the overall build process.
– start_spdk_tgt.sh and create_spdk_cfg.sh: These shell scripts demonstrate the process of unbinding default kernel drivers, binding the VFIO-PCI module, and configuring the SPDK target with the integrated FC driver.
- Integration and Deployment: The project shows clear integration steps (outlined in the README) that explain how to clone, compile, and include the FC driver module on top of SPDK.

##### Relationships and Interactions
– The SPDK NVMe target interacts with the FC driver module by invoking its APIs and receiving device I/O responses.
– The FC driver provides interfaces (via its ioctls, fabric configuration, etc.) for higher layers to configure and manage underlying Fibre Channel operations.
– Initialization and configuration scripts (start_spdk_tgt.sh, create_spdk_cfg.sh) act as the entry points for setting up the environment, handling device binding, and launching the SPDK target with FC capabilities.
- Module Interactions: Within the FC driver, represent key functional blocks such as:
– Device and driver initialization (ocs_driver, ocs_domain, ocs_device).
– IO and interrupt handling (ocs_io, ocs_ioctl, ocs_hal).
– Support routines for debugging, error recovery, and logging (ocs_debug, ocs_ras, ocs_recovery).
– Specialized protocol components that deal with Fibre Channel communication (ocs_fc and sli4 modules).

##### Architectural Patterns and Technologies
- Layered Architecture: At the highest level, the system segregates the SPDK target and the FC driver module. Within the FC driver, further separation can be emphasized:
– An abstraction layer where hardware-specific functionalities (sli4, ocs_hal) are separated from higher level management and control logic (ocs_driver, ocs_domain).
– Utility and helper libraries that implement common functionalities (e.g., CRC calculation in crc32.c, list management in ocs_list.c).
- Modular Design: The large number of discrete source files supports a modular approach where each module (e.g., authentication, fabric management, IO) is developed and maintained separately.
- Technology Stack:
– The project is written in C, built with GNU Make, and heavily integrated with SPDK and DPDK libraries (as inferred from the build instructions and the provided SPDK_DIR and DPDK_DIR references).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "External Components"
        A1["ocs_impl_spdk"]:::external
        A2["spdk_nvmf_xport"]:::external
    end

    subgraph "Build & Configuration"
        B1["Makefile"]:::script
        B2["start_spdk_tgt.sh"]:::script
        B3["create_spdk_cfg.sh"]:::script
    end

    subgraph "FC Driver Module"
        F1["src (FC driver C sources)"]:::fc
        F2["include/fc_lld.h (Headers)"]:::fc

        subgraph "Core Driver Logic"
            C1["ocs_driver"]:::core
            C2["ocs_domain"]:::core
            C3["ocs_device"]:::core
        end

        subgraph "Hardware Abstraction Layer"
            H1["ocs_hal"]:::hal
            H2["ocs_hal_queues"]:::hal
            H3["ocs_hal_rqpair"]:::hal
            H4["ocs_hal_workaround"]:::hal
            H5["sli4"]:::hal
            H6["sli4_fc"]:::hal
        end

        subgraph "IO and Control Interfaces"
            I1["ocs_ioctl"]:::io
            I2["ocs_ioctl_fc"]:::io
            I3["ocs_io"]:::io
            I4["ocs_mgmt"]:::io
        end

        subgraph "Fibre Channel Protocol Components"
            P1["ocs_els"]:::fcproto
            P2["ocs_fabric"]:::fcproto
            P3["ocs_scsi"]:::fcproto
        end

        subgraph "Utility and Support Components"
            U1["ocs_debug"]:::util
            U2["crc32"]:::util
            U3["ocs_list"]:::util
            U4["ocs_ras"]:::util
            U5["ocs_recovery"]:::util
        end
    end

    %% Data Flow Connections
    A1 -->|"calls"| C1
    A2 -->|"calls"| C1
    B2 -->|"init"| C1
    B3 -->|"config"| C1

    %% Inter-module Interactions within FC Driver Module
    C1 -->|"uses"| H1
    C1 -->|"IO"| I1
    C1 -->|"protocol"| P1
    C1 -->|"logs"| U1

    %% Integration of FC Driver Module files
    F1 --> C1
    F2 --> C1

    %% Style Definitions
    classDef external fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef script fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef fc fill:#ccffcc,stroke:#339933,stroke-width:2px;
    classDef core fill:#cce5ff,stroke:#0056b3,stroke-width:2px;
    classDef hal fill:#e6ccff,stroke:#6600cc,stroke-width:2px;
    classDef io fill:#ffe6cc,stroke:#e65c00,stroke-width:2px;
    classDef fcproto fill:#d1e0e0,stroke:#008080,stroke-width:2px;
    classDef util fill:#f2e6ff,stroke:#8a2be2,stroke-width:2px;

    %% Click Events for External Components
    click A1 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_impl_spdk.c"
    click A2 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/spdk_nvmf_xport.c"

    %% Click Events for Build and Configuration Scripts
    click B1 "https://github.com/ecdufcdrvr/bcmufctdrvr/tree/master/Makefile"
    click B2 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/start_spdk_tgt.sh"
    click B3 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/create_spdk_cfg.sh"

    %% Click Events for FC Driver Module Files
    click F1 "https://github.com/ecdufcdrvr/bcmufctdrvr/tree/master/src"
    click F2 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/include/fc_lld.h"

    %% Click Events for Core Driver Logic
    click C1 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_driver.c"
    click C2 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_domain.c"
    click C3 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_device.c"

    %% Click Events for Hardware Abstraction Layer
    click H1 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_hal.c"
    click H2 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_hal_queues.c"
    click H3 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_hal_rqpair.c"
    click H4 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_hal_workaround.c"
    click H5 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/sli4.c"
    click H6 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/sli4_fc.c"

    %% Click Events for IO and Control Interfaces
    click I1 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_ioctl.c"
    click I2 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_ioctl_fc.c"
    click I3 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_io.c"
    click I4 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_mgmt.c"

    %% Click Events for Fibre Channel Protocol Components
    click P1 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_els.c"
    click P2 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_fabric.c"
    click P3 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_scsi.c"

    %% Click Events for Utility and Support Components
    click U1 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_debug.c"
    click U2 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/crc32.c"
    click U3 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_list.c"
    click U4 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_ras.c"
    click U5 "https://github.com/ecdufcdrvr/bcmufctdrvr/blob/master/src/ocs_recovery.c"
```
