Both. Grains per gallon is a measurement of hard water, while parts per million or milgrams per liter measures the exact quantity of calcium and magnesium minerals in hard or soft water. If your drinking water has 1 PPM of hardness, it means that it contains one unit of hardness out of one million units.
PPM and mg/L are equal measurements, so 5 PPM is equal to 5 mg/L.