Giter Club home page Giter Club logo

Comments (5)

kcudnik avatar kcudnik commented on July 18, 2024

i think SAI was designed to be generic interface and not vendor specific, currently there is no specific interface to query underlying vendoer, and we should not specifically design any macros for that

from sai.

kcudnik avatar kcudnik commented on July 18, 2024

what is your motivation to have workaroudns for specific vendor ? if some apis are not implemented you will get not implemented or not supported error code and this should be your information

from sai.

bluecmd avatar bluecmd commented on July 18, 2024

Happy to hear! I agree that not relying on the vendor is a good stance to take and try to hold on to.

In my case it is only for debugging, so having something like sai_query_api_vendor_version that outputs an opaque string would suffice - like bsv (e.g. BRCM SAI ver: [8.4.0.2], OCP SAI ver: [1.11.0], SDK ver: [sdk-6.5.27] CANCUN ver: [06.04.01]).

Right now I have to resort to vendor-specific ways to get that information for my test logs, which ironically requires me to care about what module I load so I can query its non-SAI API to get the data.

That said, I based some debugging code on saithrift from this very repo and it used ifdef macros per vendor.

E.g.:

#ifdef BRCMSAI
std::thread bcm_diag_shell_thread = std::thread(sai_diag_shell);
bcm_diag_shell_thread.detach();
#endif

In my case I just removed that particular ifdef and always spawned a debug shell, but if it is indeed the case that SAI tries to be vendor agnostic maybe we should remove those from the code people otherwise use as references.

from sai.

kcudnik avatar kcudnik commented on July 18, 2024

SAI headers are generic, and there will be no vendor specific macro here, that will let you decide which SAI vendor is internally, and at SAI headers this is even impossible, since there are no vendor specific headers here. investigate SAI_SWITCH_ATTR_SWITCH_SHELL_ENABLE attribute.

We could discuss to introduce vendor string api or something like this that will return something like that, or have an enum in which will return actual vendor as unique integer, but this is broader discussion at SAI community meeting @rlhui

from sai.

bluecmd avatar bluecmd commented on July 18, 2024

For reference, this is how I currently get the data I want in my logs if anyone wants something similar:

typedef struct {
  const char* sai_api_version;
  const char* bcm_sai_version;
  const char* build_release;
  /* these are only populated after create_switch */
  const char* cancun_version;
  const char* npl_version;
} brcm_sai_version_t;

extern "C" {
extern brcm_sai_version_t* brcm_sai_version_get(brcm_sai_version_t*) __attribute__((weak));
extern void ifcs_get_version(int* major, int* minor, int* rev) __attribute__((weak));
}

/* ... */

{
  sai_api_version_t version;
  if (sai_query_api_version(&version) == SAI_STATUS_SUCCESS) {
    int major = version / 10000;
    int minor = (version - major * 10000) / 100;
    int rev = version - major * 10000 - minor * 100;
    printf("================================\n");
    printf("  Loaded SAI version %d.%d.%d\n", major, minor, rev);
  }

  if (brcm_sai_version_get != NULL) {
    brcm_sai_version_t brcm_version;
    brcm_sai_version_get(&brcm_version);
    printf(
        "\n  Broadcom SAI detected\n    SAI API version: %s\n    BRCM SAI version: %s\n    Build release: %s\n",
        brcm_version.sai_api_version,
        brcm_version.bcm_sai_version,
        brcm_version.build_release);
  }

  if (ifcs_get_version != NULL) {
    int major = 0;
    int minor = 0;
    int rev = 0;
    ifcs_get_version(&major, &minor, &rev);
    printf(
        "\n  Innovium SAI detected\n    IFCS version: %d.%d.%d\n",
        major, minor, rev);
  }

  printf("================================\n");

}

Output:

================================
  Loaded SAI version 1.11.0

  Innovium SAI detected
    IFCS version: 0.15.4
================================
================================
  Loaded SAI version 1.11.0

  Broadcom SAI detected
    SAI API version: 8.4.0.2
    BRCM SAI version: 1.11.0
    Build release: sdk-6.5.27
================================

from sai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.