Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Persistent Configuration Storage: Manages hierarchical parameter storage with support for different data types (string, integer, boolean, datetime, binary) and ensures data persistence across reboots and power cycles
  • Configuration File Management: Handles XML-based configuration file parsing, loading, validation, and storage with support for default configurations, current settings, and backup files
  • Transaction Support: Provides atomic operations for configuration updates with rollback capabilities to ensure data consistency during complex configuration changes
  • Factory Reset Support: Implements factory reset functionality that restores default configurations by removing the current and backup configuration files, triggering a reload from factory defaults on next startup
  • IPC Support: Offers RBus interfaces for parameter access, enabling integration with CCSP components and modern RBus-based services
  • HAL Integration: Provides platform-specific storage abstraction through HAL APIs, allowing adaptation to different hardware platforms and storage mechanisms
  • Configuration Validation: Validates parameter values, types, and constraints before persistence to ensure system stability and prevent invalid configurations
  • Backup and Restore: Supports configuration backup creation and restoration capabilities for system recovery and migration scenarios

Design

The CcspPsm component follows a layered architecture design that separates concerns between configuration management, storage abstraction, and inter-process communication. The design centers around three core modules: PsmSysRegistry for runtime parameter management, PsmFileLoader for configuration file handling, and the SSP (Sub-System Process) layer for IPC integration. This modular approach enables independent evolution of storage mechanisms, communication protocols, and configuration formats while maintaining stable interfaces.

...

Markdown
```mermaid
flowchart TD
    subgraph CcspPsm
        direction LR
        subgraph "SSP Layer"
            MainController[Main Controller]
            CFMInterface[CFM Interface]
        end

        subgraph "PsmSysRegistry"
            RegInterface[Registry Interface]
            RegControl[Registry Control]
            RegStorage[Registry Storage]
            RegBase[Registry Base]
            RegStates[Registry States]
        end

        subgraph "PsmFileLoader"
            FileInterface[File Loader Interface]
            FileControl[File Loader Control]
            XMLParser[XML Parser]
            FileOperations[File Operations]
            LoaderStates[Loader States]
        end
    end

    MainController --> RegInterface
    MainController --> FileInterface

    CFMInterface --> MainController

    RegInterface --> RegControl
    RegControl --> RegStorage
    RegControl --> RegStates
    RegStorage --> RegBase

    FileInterface --> FileControl
    FileControl --> XMLParser
    FileControl --> FileOperations
    FileControl --> LoaderStates

    RegStorage --> FileInterface
    FileOperations --> RegStorage
    RegStates --> FileOperations
```

Prerequisites and Dependencies

RDK-B Platform and Integration Requirements:

...

  • Threading Architecture: Single-threaded main event loop with dedicated worker threads for file I/O and backup operations
  • Main Thread: Handles RBus message processing, parameter validation, configuration updates, and maintains the in-memory parameter cache
  • Main worker Threads:
  • File I/O Thread: Manages XML configuration file reading, writing, and compression operations
  • Backup Thread: Handles periodic configuration backups and cleanup of temporary files
  • Flush Thread: Performs periodic cache flushes to persistent storage at configurable intervals
  • Synchronization: Uses mutex locks for cache access, semaphores for worker thread coordination, and atomic operations for critical flags

Component State Flow

Initialization to Active State

...

  • Configuration file updates require temporary service suspension during atomic file replacement operations
  • Factory reset operations switch to restricted mode where only essential parameters remain accessible
  • Storage fault detection triggers failover to backup storage locations with automatic recovery attempts

Call Flow

Initialization Call Flow:

...

Markdown
```mermaid
sequenceDiagram
    participant Client as RDK-B Component
    participant PSM as CcspPsm Main Thread
    participant Cache as Parameter Cache
    participant Storage as Persistent Storage
    participant HAL as Platform HAL

    Client->>PSM: Parameter Get Request (RBus)
    PSM->>Cache: Check Parameter Cache
    Cache-->>PSM: Cache Hit/Miss Result
    alt Cache Miss
        PSM->>Storage: Load from Persistent Storage
        Storage-->>PSM: Parameter Value Retrieved
        PSM->>Cache: Update Cache Entry
    end
    PSM-->>Client: Parameter Value Response

    Client->>PSM: Parameter Set Request (RBus)
    PSM->>PSM: Validate Parameter Value
    PSM->>Cache: Update Cache Entry
    PSM->>Storage: Schedule Persistent Write
    PSM->>HAL: Platform-Specific Update (if needed)
    HAL-->>PSM: Update Confirmation
    PSM-->>Client: Set Operation Response
```

Internal Modules

The CcspPsm component is structured into three primary modules that handle different aspects of persistent storage management. The PsmSysRegistry module manages the runtime parameter registry and in-memory caching, providing high-performance parameter access and validation. The PsmFileLoader module handles XML configuration file operations including parsing, validation, and file management for default, current, and backup configurations. The SSP (Sub-System Process) module provides the interface layer for RBus communications, HAL integration, and system service management.

Module/ClassDescriptionKey Files
PsmSysRegistryManages runtime parameter registry, in-memory cache operations, parameter validation, and provides atomic transaction support for configuration updatespsm_sysro_interface.c, psm_sysro_control.c, psm_sysro_storage.c, psm_sysro_base.c
PsmFileLoaderHandles XML configuration file parsing, validation, loading of default configurations, and manages backup/restore operations with compression supportpsm_flo_interface.c, psm_flo_parse.c, psm_flo_operation.c, psm_flo_control.c
SSP LayerProvides RBus interface implementations, HAL integration layer, main process control, and system service management including signal handlingssp_main.c, ssp_rbus.c, ssp_cfmif.c, psm_hal_apis.c

Component Interactions

CcspPsm serves as the central configuration repository for the RDK-B middleware ecosystem, interfacing with numerous components through standardized IPC mechanisms. The component provides RBus interfaces to accommodate modern RBus-based services and CCSP components. It integrates with platform HAL layers for hardware-specific storage operations and communicates with external management systems through TR-069 and web interfaces.

Interaction Matrix

Target Component/LayerInteraction PurposeKey APIs/Endpoints
RDK-B Middleware Components

CcspPandMConfiguration parameter management, system status reporting, factory reset coordinationGetPSMRecordValue(), SetPSMRecordValue()
CcspTr069PaTR-069 parameter persistence, ACS configuration storage, device provisioning datagetParameterValues(), setParameterValues(), addObject()
OneWifiWiFi configuration persistence, radio settings, access point parametersDevice.WiFi. namespace parameters, WiFi credential storage
CcspDmCliCommand-line data model access, diagnostic parameter retrieval, testing interfaceRBus method calls for parameter tree navigation
System & HAL Layers

Syscfg HALPlatform-specific configuration parameter access, hardware-dependent settingssyscfg_get(), syscfg_unset(), syscfg_commit()
File SystemConfiguration file storage, backup operations, temporary file management/psm/config/psm_*_cfg.xml.gz, /tmp/bbhm_cur_cfg.xml, /nvram/bbhm_bak_cfg.xml
Platform ServicesSystem integration, service lifecycle management, resource monitoringSystemd unit file control, process monitoring

IPC Flow Patterns

Primary IPC Flow - Parameter Get/Set Operations:

...

Markdown
```mermaid
sequenceDiagram
    participant Client as Configuration Client
    participant PSM as CcspPsm Process
    participant RBus as RBus Event System
    participant Sub1 as CcspPandM
    participant Sub2 as CcspTr069Pa

    Client->>PSM: Set Parameter Request
    PSM->>PSM: Update Parameter Value
    PSM->>PSM: Check for Value Change
    alt Value Changed
        PSM->>RBus: Publish ParameterValueChanged Event
        RBus->>Sub1: Event Notification (RBus)
        RBus->>Sub2: Event Notification (IPC)
        Sub1-->>PSM: Event Acknowledgment (if required)
        Sub2-->>PSM: Event Acknowledgment (if required)
    end
    PSM-->>Client: Set Operation Complete
```

Implementation Details

Major HAL APIs Integration

CcspPsm integrates with platform-provided Syscfg APIs for persistent storage and configuration access. These APIs are consumed by CcspPsm code in ssp_cfmif.c, but their implementation and ownership are external to this repository.

...

HAL APIPurposeParametersReturn ValuesImplementation / Ownership
syscfg_get()Retrieve a platform-specific configuration parameter from persistent storage4-argument form: syscfg_get(NULL, key, buf, size)0 on success, non-zero on errorExternal Syscfg API consumed in ssp_cfmif.c; not implemented in this repository
syscfg_unset()Remove a platform-specific configuration parameter from persistent storage2-argument form: syscfg_unset(NULL, key)0 on success, non-zero on errorExternal Syscfg API consumed in ssp_cfmif.c; not implemented in this repository
PsmHal_GetCustomParams()Retrieve platform-specific default parameters for initial configurationPsmHalParam_t** params, int* cnt0 on success, -1 on failure or no custom parameterspsm_hal_apis.c

Key Implementation Logic

  • Parameter Registry Engine: Core parameter management logic implemented in psm_sysro_interface.c with hash-based parameter lookup, type validation, and atomic update operations. Main registry implementation in psm_sysro_base.c with parameter tree management and namespace handling. State transition handlers in psm_sysro_states.c for parameter lifecycle management and event processing.
  • Configuration File Processing: XML configuration file parsing is handled using the ANSC XML DOM APIs (e.g., AnscCreateXmlDomNode, AnscXmlDomNodeEncode). The configuration parsing engine in psm_flo_parse.c performs XML document handling and parameter extraction, with validation limited to the checks implemented in the parser and surrounding configuration-loading logic. Configuration load/save and related file control logic is in psm_flo_control.c (for example, PsmFloLoadRegFile() and PsmFloSaveRegFile()). Configuration loading state machine in psm_flo_states.c for startup and runtime configuration management.

  • Error Handling Strategy: Comprehensive error detection and recovery mechanisms for storage failures, parsing errors, and IPC communication issues. HAL error code mapping with automatic retry mechanisms for transient failures. Configuration validation with rollback support for invalid parameter updates. Graceful degradation with emergency read-only mode when persistent storage fails.

  • Logging & Debugging: Multi-level logging system with component-specific categories and runtime verbosity control. Parameter operation logging with value change tracking and audit trail. File operation tracing with performance metrics and error diagnostics. RBus message tracing for IPC debugging and performance analysis.

Key Configuration Files

Configuration FilePurposeKey ParametersDefault ValuesOverride Mechanisms
/psm/config/psm_def_cfg.xml.gzDefault/base configuration (maps to PSM_DEF_DEF_FILE_NAME)All default parameter valuesFactory defaultsReplacement via update procedure
/psm/config/psm_cur_cfg.xml.gzCurrent persistent configuration (maps to PSM_DEF_CUR_FILE_NAME)All runtime parametersPopulated from default configParameter Set operations, configuration import
/psm/config/psm_bak_cfg.xml.gzBackup persisted configuration archive (maps to PSM_DEF_BAK_FILE_NAME)Previous stable configuration setPrevious persisted current configurationAutomatic backup/restore workflow
/tmp/bbhm_cur_cfg.xmlRuntime working copy of current active configuration (PSM_CUR_CONFIG_FILE_NAME in ssp_cfmif.c)All runtime parametersPopulated from persistent configParameter Set operations
/nvram/bbhm_bak_cfg.xmlRuntime backup configuration (PSM_BAK_CONFIG_FILE_NAME in ssp_cfmif.c)Previous stable configurationPrevious current configAutomatic backup on major changes