> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AR Utility Err Detection

> Header for SPF error detection framework.

**Header:** `ar_util/api/ar_util_err_detection.h`

## Functions

### `ar_err_det_init_ctxt`

Initializes one error detection context.

Multiple error detection contexts are useful in multi-master DSP scenarios, so that a fatal error on one master does not require the other to restart. The error detection context stores some persistent data which is used in error analysis

```cpp theme={null}
int32_t ar_err_det_init_ctxt(uint32_t proc_handle, void *client_data)
```

**Parameters**

**proc\_handle** `uint32_t`

the master proc to initialize context for

**client\_data** `void *`

data to return when this master proc needs restart

**Returns**

AR\_EOK : on success AR\_E\<other error> : on failure

### `ar_err_det_destroy_ctxt`

Destroys one error detection context.

Multiple error detection contexts are useful in multi-master SPF scenarios, so that a fatal error on one master does not require the other to restart

```cpp theme={null}
int32_t ar_err_det_destroy_ctxt(uint32_t proc_handle)
```

**Parameters**

**proc\_handle** `uint32_t`

the master proc to destroy context for

**Returns**

AR\_EOK : on success AR\_E\<other error> : on failure

### `ar_err_det_reset_ctxt`

Reset state variables for an error detection context.

After SSR or PDR we must reset state variables in a context, like time since last restart or number of timeouts logged. This API will not reset the client data stored on context init.

```cpp theme={null}
int32_t ar_err_det_reset_ctxt(uint32_t proc_handle)
```

**Parameters**

**proc\_handle** `uint32_t`

the master proc ID to reset the context for

**Returns**

AR\_EOK : on success AR\_E\<other error> : on failure

### `ar_err_det_detect_spf_error`

Determines whether SPF is in an unrecoverable state.

Multiple error detection contexts are useful in multi-master DSP scenarios, so that a fatal error on one master does not require the other to restart We identify them by the proc\_id.

\dependencies None

```cpp theme={null}
int32_t ar_err_det_detect_spf_error(uint32_t proc_handle, int32_t err_code, uint32_t opcode, bool_t *do_restart, void **client_data)
```

**Parameters**

**proc\_handle** `uint32_t`

the master proc to use for error analysis

**err\_code** `int32_t`

the error code returned by SPF

**opcode** `uint32_t`

the opcode for which the error code was returned

**do\_restart** `bool_t *`

true when serious error requiring restart is detected. false otherwise

**client\_data** `void **`

data to return when this master proc needs restart.

**Returns**

AR\_EOK : on successful error analysis, meaning do\_restart is valid AR\_E\<other error> : otherwise, meaning do\_restart should be ignored
