DPACC API Guidelines 2019/10/12.

Slides:



Advertisements
Similar presentations
Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
Advertisements

Generalized Requests. The current definition They are defined in MPI 2 under the hood of the chapter 8 (External Interfaces) Page 166 line 16 The objective.
C Language.
Structures Spring 2013Programming and Data Structure1.
Memory allocation CSE 2451 Matt Boggus. sizeof The sizeof unary operator will return the number of bytes reserved for a variable or data type. Determine:
Chapter 6: Functions.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
CS-1030 Dr. Mark L. Hornick 1 Pointers are fun!
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
LAB 12: Timer and Interrupt Chung-Ta King National Tsing Hua University CS 4101 Introduction to Embedded Systems.
Assembly Language for x86 Processors 7th Edition Chapter 13: High-Level Language Interface (c) Pearson Education, All rights reserved. You may modify.
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
CSCI 171 Presentation 6 Functions and Variable Scope.
Chapter 11 – Pointer Variables. Declaring a Pointer Variable u Declared with data type, * and identifier type* pointer_variable; u * follows data type.
How to write a MSGQ Transport (MQT) Overview Nov 29, 2005 Todd Mullanix.
Functions Chapter 6. Modular Programming Modular programming: breaking a program up into smaller, manageable functions or modules Function: a collection.
Virtio-IPsec-LA PoC Implementation
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Functions Outline 3.15Functions with Empty Parameter Lists 3.16Inline Functions 3.17References.
C++ Programming Lecture 13 Functions – Part V By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
DPACC Metadata Revised 2016/3/21. Table of Contents Motivation Information Elements Data representation Convergence discussion for IFA004.
1 Chapter 12 Classes and Abstraction. 2 Chapter 12 Topics Meaning of an Abstract Data Type Declaring and Using a class Data Type Using Separate Specification.
Chapter 12 Classes and Abstraction
C++ Lesson 1.
Principles of programming languages 10: Object oriented languages
Test 2 Review Outline.
Chapter 13: Overloading and Templates
Chapter 7: User-Defined Functions II
APPENDIX a WRITING SUBROUTINES IN C
CS1010 Programming Methodology
Introduction to C++ Systems Programming.
FUNCTIONS In C++.
Introduction to Classes
Linux device driver development
Chapter 15: Overloading and Templates
Student Book An Introduction
Visit for more Learning Resources
High-Level Language Interface
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
CSCI 161: Introduction to Programming Function
Chapter 6: Functions Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
This pointer, Dynamic memory allocation, Constructors and Destructor
Dynamic Memory Allocation
Buy book Online -
Chapter 14 - Advanced C Topics
CS212: Object Oriented Analysis and Design
Pointers, Dynamic Data, and Reference Types
Chapter 15 Pointers, Dynamic Data, and Reference Types
Dr. Bhargavi Dept of CS CHRIST
Reference Parameters.
Classes and Objects.
References, const and classes
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
9-10 Classes: A Deeper Look.
Guidelines for Writing Functions
Arrays Arrays A few types Structures of related data items
Submitted By : Veenu Saini Lecturer (IT)
Update Summary of DPACC docs
Recitation Course 0603 Speaker: Liu Yu-Jiun.
CS410 – Software Engineering Lecture #5: C++ Basics III
Standard Version of Starting Out with C++, 4th Edition
9-10 Classes: A Deeper Look.
四時讀書樂 (春) ~ 翁森 山光照檻水繞廊,舞雩歸詠春風香。 好鳥枝頭亦朋友,落花水面皆文章。 蹉跎莫遣韶光老,人生唯有讀書好。
Update Summary of DPACC docs
Platform Performance Acceleration
Latest Update DPACC Use-cases
Accelerator Management g-API’s
Introduction to Classes and Objects
Presentation transcript:

DPACC API Guidelines 2019/10/12

Motivation One needs different g-API suite for different use-case Specify generally applicable guidelines for DPACC g-API

Table of Contents Basic Types API Naming Convention Variable Naming convention Function Convention Example

Basic Types Linux type definitions shall be followed. For example int, u64, char etc. shall be used. https://www.kernel.org/doc/Documentation/CodingStyle http://www.gnu.org/prep/standards/standards.html All the enum should be declared to support the binary compatibility. For ex: enum g_pdcp_sn_size { G_PDCP_SN_SIZE_5=5, G_PDCP_SN_SIZE_7=7, G_PDCP_SN_SIZE_12=12, G_PDCP_SN_SIZE_15=15, };

API Naming convention Structure What needs to be conveyed in an API name? API type: g-API? S-API? … Acceleration Functionality: Crypto? IPSec? PDCP? Acceleration Model: Lookaside? Inline? Data Path Offload? Operation: Open? Close? Process? Common operations: open? Close? Specific operations: encap/decap/flush Suffix Common name: api_version Specific name: sa for IPSec (g_ipsec_la_add_sa) sec for PDCP (g_pdcp_la_add_sec) Proposal apiname = apitype ‘_’accfunc ‘_’accmodel ‘_’operation ‘_’ suffix e.g. g_ipsec_la_get_api_version

API Naming convention Syntax What could be filled with each elements in an API name? API type: g-API? S-API? Acceleration Functionality: Crypto? IPSec? PDCP? Acceleration Model: Lookaside? Inline? Data Path Offload? Operation: Open? Close? Process? Common operations: open? Close? Specific operations: Suffix Common name: api_version Specific name: SA@IPSec Out of scope of this proposal dpacc arch dpacc usecase dpacc usecase Propose to be included in intended doc Propose to be illustrated in intended doc

API Naming convention Operations This operations can generic like Open, Close, Add, Del, Mod, Get ,Process. It can be extended with specific operation names, based on the accelerator’s need. For Ex: flush, invoke, register, send, poll, etc ., Examples: g_ipsec_la_open g_pdcp_la_close g_ipsec_la_flush_sa g_pdcp_la_poll open - opens the accelerator close - closes the accelerator get - gets the info set - sets the info add - adds the info modify - modifies the info delete - deletes the info find - finds the info process - processes the data notify - notification

API Naming convention Common names api_version open close Examples: g_ipsec_la_get_api_version g_pdcp_la_get_api_version

Variable Naming Convention Naming convention for variables shall follow Linux style, readable and separated by underscore, when necessary.

Function Convention Return Values SUCCESS (0) or FAILURE (-1). Can we go with –ve value for failure and +ve for success message. For Ex: G_XYZ_XYZ_GENERAL_SUCCESS 0 G_XYZ_XYZ_RECORD_ADD_SUCCESS 1 G_XYZ_XYZ_NO_DUPLICATE_RECORD_FOUND 2 G_XYZ_XYZ_GENERAL_FAILURE -1 G_XYZ_XYZ_MEMORY_ALLOC_FAIL -2 G_XYZ_XYZ_DUPLICATE_RECORD_FOUND -3 Do we need to reserve and common errcodes accelerator ? ACCELERATOR_AVAILABLE 0 ACCELERATOR_NOT_AVAILABLE -1 RESERVED_ERROR_CODE_BASE 1024 G_ACC_1_ERROR_CODE_START RESERVED_ERROR_CODE_BASE+1 G_ACC_1_ERROR_CODE_END RESERVED_ERROR_CODE_BASE+1024 G_ACC_2_ERROR_CODE_START G_ACC_1_ERROR_CODE_END +1 G_ACC_2_ERROR_CODE_END G_ACC_1_ERROR_CODE_END +1024

Function Convention Control Function Parameters Int g_ipsec_la_add_sa( struct g_ipsec_la_handle *handle, /* Accelerator handle */ const struct g_ipsec_la_add_sa_inargs *in, /* Input */ enum g_ipsec_la_control_flags flags, /* API flags */ struct g_ipsec_la_add_sa_outargs *out, /* Output */ struct g_ipsec_la_resp_args resp /* response callback in case asynchronous mode with response flag is set */ ); Group the input and output values to an inargs/outarg structure.

Function Convention Data Processing Function Parameters int32_t g_ipsec_la_packet_encap( struct g_ipsec_la_handle *handle, struct g_ipsec_la_control_flags flags, struct g_ipsec_la_sa_handle *handle; /* SA Handle */ uint32 num_sg_elem; /* num of Scatter Gather elements */ struct g_ipsec_la_data in_data[]; /* Array of data blocks */ struct g_ipsec_la_data out_data[]; /* Array of output data blocks */ struct g_api_resp_args resp ) For control or setup APIs that are used to setup states in the hardware accelerator it is preferable to use data structures to pass input and output parameters. While these setup or control functions do not come in the data path and hence do not impact performance, having parameters defined as structures enables extensibility in future without changing API prototypes. Structure introduced for passing in as parameters for functions shall have the function name as prefix and inargs/outargs as suffixes to indicate input and output arguments. struct g_ipsec_la_data contains a ptr and length of the buffer. This method is used instead of buffer ptr itself to avoid using application specific buffers in the driver. This way, the driver independent of buffers used in SAL, which could be either skb in linux kernel, rte_mbuf in DPDK or odp_buffer in ODP.. Array is used to allow fragmented buffer.

Function Parameters Control Flags (An Example) enum g_ipsec_la_control_flags { G_IPSEC_LA_CTRL_FLAG_ASYNC=1, /* If Set, API call be asynchronous. Otherwise, API call will be synchronous */ G_IPSEC_LA_CTRL_FLAG_NO_RESP_EXPECTED=2, /* If set, no response is expected for this API call */ }; Application can request the response to be returned synchronously or asynchronously (G_IPSEC_LA_CTRL_FLAG_ASYNC). If the response is requested asynchronously, then the application should provide a callback function pointer and callback argument. Also, in some scenarios, the API layer may have to do additional operations to force a response from the backend. The flag G_IPSEC_LA_CTRL_FLAG_NO_RESP_EXPECTED can be used by application to indicate whether the application should force the response from the backend or not.

Function Parameters Response Args (An example) struct g_ipsec_la_resp_args { struct g_ipsec_la_resp_cbfn cb_fn; /* Callback function if ASYNC flag is chosen */ void *cb_arg; int32_t cb_arg_len; /* Callback argument length */ }

Example