.TH "rte_spinlock.h" 3 "Version 25.11.0" "DPDK" \" -*- nroff -*-
.ad l
.nh
.SH NAME
rte_spinlock.h
.SH SYNOPSIS
.br
.PP
\fR#include <rte_lcore\&.h>\fP
.br
\fR#include <rte_lock_annotations\&.h>\fP
.br
\fR#include <rte_pause\&.h>\fP
.br
\fR#include <rte_stdatomic\&.h>\fP
.br

.SS "Data Structures"

.in +1c
.ti -1c
.RI "struct \fBrte_spinlock_t\fP"
.br
.ti -1c
.RI "struct \fBrte_spinlock_recursive_t\fP"
.br
.in -1c
.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fBRTE_SPINLOCK_INITIALIZER\fP   { 0 }"
.br
.ti -1c
.RI "#define \fBRTE_SPINLOCK_RECURSIVE_INITIALIZER\fP   {\fBRTE_SPINLOCK_INITIALIZER\fP, \-1, 0}"
.br
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "static void \fBrte_spinlock_init\fP (\fBrte_spinlock_t\fP *sl)"
.br
.ti -1c
.RI "static void \fBrte_spinlock_lock\fP (\fBrte_spinlock_t\fP *sl)"
.br
.ti -1c
.RI "static void \fBrte_spinlock_unlock\fP (\fBrte_spinlock_t\fP *sl)"
.br
.ti -1c
.RI "static \fB__rte_warn_unused_result\fP int \fBrte_spinlock_trylock\fP (\fBrte_spinlock_t\fP *sl) sl)"
.br
.ti -1c
.RI "static int \fBrte_spinlock_is_locked\fP (\fBrte_spinlock_t\fP *sl)"
.br
.ti -1c
.RI "static int \fBrte_tm_supported\fP (void)"
.br
.ti -1c
.RI "static void \fBrte_spinlock_lock_tm\fP (\fBrte_spinlock_t\fP *sl)"
.br
.ti -1c
.RI "static void \fBrte_spinlock_unlock_tm\fP (\fBrte_spinlock_t\fP *sl)"
.br
.ti -1c
.RI "static \fB__rte_warn_unused_result\fP int \fBrte_spinlock_trylock_tm\fP (\fBrte_spinlock_t\fP *sl) sl)"
.br
.ti -1c
.RI "static void \fBrte_spinlock_recursive_init\fP (\fBrte_spinlock_recursive_t\fP *slr)"
.br
.ti -1c
.RI "static void \fBrte_spinlock_recursive_lock\fP (\fBrte_spinlock_recursive_t\fP *slr) __rte_no_thread_safety_analysis"
.br
.ti -1c
.RI "static void \fBrte_spinlock_recursive_unlock\fP (\fBrte_spinlock_recursive_t\fP *slr) __rte_no_thread_safety_analysis"
.br
.ti -1c
.RI "static \fB__rte_warn_unused_result\fP int \fBrte_spinlock_recursive_trylock\fP (\fBrte_spinlock_recursive_t\fP *slr) __rte_no_thread_safety_analysis"
.br
.ti -1c
.RI "static void \fBrte_spinlock_recursive_lock_tm\fP (\fBrte_spinlock_recursive_t\fP *slr)"
.br
.ti -1c
.RI "static void \fBrte_spinlock_recursive_unlock_tm\fP (\fBrte_spinlock_recursive_t\fP *slr)"
.br
.ti -1c
.RI "static \fB__rte_warn_unused_result\fP int \fBrte_spinlock_recursive_trylock_tm\fP (\fBrte_spinlock_recursive_t\fP *slr)"
.br
.in -1c
.SH "Detailed Description"
.PP 
RTE Spinlocks

.PP
This file defines an API for read-write locks, which are implemented in an architecture-specific way\&. This kind of lock simply waits in a loop repeatedly checking until the lock becomes available\&.

.PP
All locks must be initialised before use, and only initialised once\&. 
.PP
Definition in file \fBrte_spinlock\&.h\fP\&.
.SH "Macro Definition Documentation"
.PP 
.SS "#define RTE_SPINLOCK_INITIALIZER   { 0 }"
A static spinlock initializer\&. 
.PP
Definition at line \fB42\fP of file \fBrte_spinlock\&.h\fP\&.
.SS "#define RTE_SPINLOCK_RECURSIVE_INITIALIZER   {\fBRTE_SPINLOCK_INITIALIZER\fP, \-1, 0}"
A static recursive spinlock initializer\&. 
.PP
Definition at line \fB207\fP of file \fBrte_spinlock\&.h\fP\&.
.SH "Function Documentation"
.PP 
.SS "void rte_spinlock_init (\fBrte_spinlock_t\fP * sl)\fR [inline]\fP, \fR [static]\fP"
Initialize the spinlock to an unlocked state\&.

.PP
\fBParameters\fP
.RS 4
\fIsl\fP A pointer to the spinlock\&. 
.RE
.PP

.PP
Definition at line \fB51\fP of file \fBrte_spinlock\&.h\fP\&.
.SS "void rte_spinlock_lock (\fBrte_spinlock_t\fP * sl)\fR [inline]\fP, \fR [static]\fP"
Take the spinlock\&.

.PP
\fBParameters\fP
.RS 4
\fIsl\fP A pointer to the spinlock\&. 
.RE
.PP

.SS "void rte_spinlock_unlock (\fBrte_spinlock_t\fP * sl)\fR [inline]\fP, \fR [static]\fP"
Release the spinlock\&.

.PP
\fBParameters\fP
.RS 4
\fIsl\fP A pointer to the spinlock\&. 
.RE
.PP

.SS "\fB__rte_warn_unused_result\fP int rte_spinlock_trylock (\fBrte_spinlock_t\fP * sl)\fR [inline]\fP, \fR [static]\fP"
Try to take the lock\&.

.PP
\fBParameters\fP
.RS 4
\fIsl\fP A pointer to the spinlock\&. 
.RE
.PP
\fBReturns\fP
.RS 4
1 if the lock is successfully taken; 0 otherwise\&. 
.RE
.PP

.SS "int rte_spinlock_is_locked (\fBrte_spinlock_t\fP * sl)\fR [inline]\fP, \fR [static]\fP"
Test if the lock is taken\&.

.PP
\fBParameters\fP
.RS 4
\fIsl\fP A pointer to the spinlock\&. 
.RE
.PP
\fBReturns\fP
.RS 4
1 if the lock is currently taken; 0 otherwise\&. 
.RE
.PP

.PP
Definition at line \fB133\fP of file \fBrte_spinlock\&.h\fP\&.
.SS "int rte_tm_supported (void )\fR [inline]\fP, \fR [static]\fP"
Test if hardware transactional memory (lock elision) is supported

.PP
\fBReturns\fP
.RS 4
1 if the hardware transactional memory is supported; 0 otherwise\&. 
.RE
.PP

.SS "void rte_spinlock_lock_tm (\fBrte_spinlock_t\fP * sl)\fR [inline]\fP, \fR [static]\fP"
Try to execute critical section in a hardware memory transaction, if it fails or not available take the spinlock\&.

.PP
NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail\&. Therefore, hardware transactional locks are not advised to be used around \fBrte_eth_rx_burst()\fP and \fBrte_eth_tx_burst()\fP calls\&.

.PP
\fBParameters\fP
.RS 4
\fIsl\fP A pointer to the spinlock\&. 
.RE
.PP

.SS "void rte_spinlock_unlock_tm (\fBrte_spinlock_t\fP * sl)\fR [inline]\fP, \fR [static]\fP"
Commit hardware memory transaction or release the spinlock if the spinlock is used as a fall-back

.PP
\fBParameters\fP
.RS 4
\fIsl\fP A pointer to the spinlock\&. 
.RE
.PP

.SS "\fB__rte_warn_unused_result\fP int rte_spinlock_trylock_tm (\fBrte_spinlock_t\fP * sl)\fR [inline]\fP, \fR [static]\fP"
Try to execute critical section in a hardware memory transaction, if it fails or not available try to take the lock\&.

.PP
NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail\&. Therefore, hardware transactional locks are not advised to be used around \fBrte_eth_rx_burst()\fP and \fBrte_eth_tx_burst()\fP calls\&.

.PP
\fBParameters\fP
.RS 4
\fIsl\fP A pointer to the spinlock\&. 
.RE
.PP
\fBReturns\fP
.RS 4
1 if the hardware memory transaction is successfully started or lock is successfully taken; 0 otherwise\&. 
.RE
.PP

.SS "void rte_spinlock_recursive_init (\fBrte_spinlock_recursive_t\fP * slr)\fR [inline]\fP, \fR [static]\fP"
Initialize the recursive spinlock to an unlocked state\&.

.PP
\fBParameters\fP
.RS 4
\fIslr\fP A pointer to the recursive spinlock\&. 
.RE
.PP

.PP
Definition at line \fB215\fP of file \fBrte_spinlock\&.h\fP\&.
.SS "void rte_spinlock_recursive_lock (\fBrte_spinlock_recursive_t\fP * slr)\fR [inline]\fP, \fR [static]\fP"
Take the recursive spinlock\&.

.PP
\fBParameters\fP
.RS 4
\fIslr\fP A pointer to the recursive spinlock\&. 
.RE
.PP

.PP
Definition at line \fB228\fP of file \fBrte_spinlock\&.h\fP\&.
.SS "void rte_spinlock_recursive_unlock (\fBrte_spinlock_recursive_t\fP * slr)\fR [inline]\fP, \fR [static]\fP"
Release the recursive spinlock\&.

.PP
\fBParameters\fP
.RS 4
\fIslr\fP A pointer to the recursive spinlock\&. 
.RE
.PP

.PP
Definition at line \fB245\fP of file \fBrte_spinlock\&.h\fP\&.
.SS "\fB__rte_warn_unused_result\fP int rte_spinlock_recursive_trylock (\fBrte_spinlock_recursive_t\fP * slr)\fR [inline]\fP, \fR [static]\fP"
Try to take the recursive lock\&.

.PP
\fBParameters\fP
.RS 4
\fIslr\fP A pointer to the recursive spinlock\&. 
.RE
.PP
\fBReturns\fP
.RS 4
1 if the lock is successfully taken; 0 otherwise\&. 
.RE
.PP

.PP
Definition at line \fB264\fP of file \fBrte_spinlock\&.h\fP\&.
.SS "void rte_spinlock_recursive_lock_tm (\fBrte_spinlock_recursive_t\fP * slr)\fR [inline]\fP, \fR [static]\fP"
Try to execute critical section in a hardware memory transaction, if it fails or not available take the recursive spinlocks

.PP
NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail\&. Therefore, hardware transactional locks are not advised to be used around \fBrte_eth_rx_burst()\fP and \fBrte_eth_tx_burst()\fP calls\&.

.PP
\fBParameters\fP
.RS 4
\fIslr\fP A pointer to the recursive spinlock\&. 
.RE
.PP

.SS "void rte_spinlock_recursive_unlock_tm (\fBrte_spinlock_recursive_t\fP * slr)\fR [inline]\fP, \fR [static]\fP"
Commit hardware memory transaction or release the recursive spinlock if the recursive spinlock is used as a fall-back

.PP
\fBParameters\fP
.RS 4
\fIslr\fP A pointer to the recursive spinlock\&. 
.RE
.PP

.SS "\fB__rte_warn_unused_result\fP int rte_spinlock_recursive_trylock_tm (\fBrte_spinlock_recursive_t\fP * slr)\fR [inline]\fP, \fR [static]\fP"
Try to execute critical section in a hardware memory transaction, if it fails or not available try to take the recursive lock

.PP
NOTE: An attempt to perform a HW I/O operation inside a hardware memory transaction always aborts the transaction since the CPU is not able to roll-back should the transaction fail\&. Therefore, hardware transactional locks are not advised to be used around \fBrte_eth_rx_burst()\fP and \fBrte_eth_tx_burst()\fP calls\&.

.PP
\fBParameters\fP
.RS 4
\fIslr\fP A pointer to the recursive spinlock\&. 
.RE
.PP
\fBReturns\fP
.RS 4
1 if the hardware memory transaction is successfully started or lock is successfully taken; 0 otherwise\&. 
.RE
.PP

.SH "Author"
.PP 
Generated automatically by Doxygen for DPDK from the source code\&.
